Sockets: Difference between revisions
m
→{{header|Frink}}: Fixed port number
m (→{{header|Phix}}: syntax coloured, marked p2js incompatible) |
m (→{{header|Frink}}: Fixed port number) |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 7:
=={{header|Ada}}==
{{libheader|GNAT RTL}}
<
procedure Socket_Send is
Line 20:
String'Write (Stream (Client), "hello socket world");
Close_Socket (Client);
end Socket_Send;</
=={{header|Aime}}==
<
tcpip_connect(i, o, "127.0.0.1", 256, 0);
i.text("hello socket world");</
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">socket: connect.to:"localhost" 256
send socket "Hello Socket World"
unplug socket</syntaxhighlight>
=={{header|AutoHotkey}}==
modified from
[http://www.autohotkey.com/forum/topic13829.html script] by zed gecko.
<
Network_Address = 127.0.0.1
NewData := false
Line 154 ⟶ 159:
ExitSub:
DllCall("Ws2_32\WSACleanup")
ExitApp</
=={{header|AutoIt}}==
<
TCPStartup()
$Socket = TCPConnect("127.0.0.1", 256)
Line 164 ⟶ 169:
TCPCloseSocket($Socket)
TCPShutdown()
EndFunc</
=={{header|AWK}}==
Line 171 ⟶ 176:
Server:
<
s="/inet/tcp/256/0/0"
print strftime() |& s
close(s)
}
</syntaxhighlight>
Test client:
<
s="/inet/tcp/0/localhost/256"
s |& getline
print $0
close(s)
}</
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<
PROC_initsockets
Line 199 ⟶ 204:
PROC_closesocket(socket%)
PROC_exitsockets</
=={{header|C}}==
Line 208 ⟶ 213:
With little changes it could work on MS Windows (without Cygwin) too. But I don't know exactly how. I have tested it using <code>nc -l -p 256</code>.
<
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
const char *msg = "hello socket world";
Line 244 ⟶ 250:
freeaddrinfo(addrs);
}
}</
=={{header|C sharp|C#}}==
<
using System.IO;
using System.Net.Sockets;
Line 262 ⟶ 268:
tcp.Close();
}
}</
Clean Socket alternative:
<
using System.Net.Sockets;
Line 281 ⟶ 287:
}
}
}</
=={{header|C++}}==
I have tested it using <code>nc -vlp 4321</code>.
<
#include <boost/asio.hpp>
Line 301 ⟶ 307:
return 0;
}</
=={{header|Cind}}==
<
var libsocket = @("lib","socket");
// connect
Line 318 ⟶ 324:
// close socket
libsocket.close(socket);
</syntaxhighlight>
=={{header|Clojure}}==
<
(:import (java.net Socket)
(java.io PrintWriter)))
Line 330 ⟶ 336:
(.println printer msg)))
(send-data "localhost" "hello socket world")</
=={{header|Common Lisp}}==
Line 336 ⟶ 342:
{{libheader|usocket}}
<
(write-line "hello socket world" stream)
(values))
; No value</
<
hello socket world</
=={{header|D}}==
<
import std.stdio ;
import std.socket ;
Line 359 ⟶ 365:
writefln("Socket %d bytes sent.", res) ;
socket.close() ;
}</
=={{header|Delphi}}==
<
{$APPTYPE CONSOLE}
Line 380 ⟶ 386:
lTCPClient.Free;
end;
end.</
=={{header|Elena}}==
ELENA 4.1 :
<
import system'text;
import extensions'text;
Line 396 ⟶ 402:
socket.write(AnsiEncoder.toByteArray(0, s.Length, s));
socket.close()
}</
=={{header|Elixir}}==
<syntaxhighlight lang="elixir">
defmodule Sockets do
require Logger
Line 410 ⟶ 416:
Sockets.send_message(256, "hello socket world")
</syntaxhighlight>
=={{header|Emacs Lisp}}==
Line 416 ⟶ 422:
Emacs treats network connections as sub-processes. <code>make-network-process</code> is the low-level socket creation,
<
:host 'local ;; or hostname string
:service 256)))
(process-send-string proc "hello socket world")
(delete-process proc))</
=={{header|Erlang}}==
<
-export([start/0]).
Line 431 ⟶ 437:
ok = gen_tcp:send(Sock, "hello socket world"),
ok = gen_tcp:close(Sock).
</syntaxhighlight>
=={{header|Factor}}==
<
=={{header|Fantom}}==
<
using inet
Line 453 ⟶ 459:
}
}
</syntaxhighlight>
=={{header|Forth}}==
{{works with|GNU Forth|0.7.0}}
<
s" localhost" 256 open-socket
Line 463 ⟶ 469:
dup s" hello socket world" rot write-socket
close-socket</
=={{header|FreeBASIC}}==
{{libheader|winsock}}
{{works with|Windows FreeBASIC}}
<syntaxhighlight lang="vbnet">' We import the windows sockets library
#Include Once "windows.bi"
#Include Once "win/winsock.bi"
#include "fbgfx.bi"
#define NET_BUFLEN 1024
'--- SENDER ---
Dim As WSADATA wsaData
Dim As SOCKET sendSocket
Dim As sockaddr_in recvAddr
Dim As Integer port = 256
Dim As Ubyte sendBuf(NET_BUFLEN-1)
Dim As Integer bufLen = NET_BUFLEN
Dim As Integer iResult
Dim As String message = "hello socket world"
' We copy the message to the buffer
For i As Ubyte = 1 To Len(message)
sendBuf(i-1) = Cbyte(Asc(Mid(message, i, 1)))
Next
' We update bufLen to be the length of the message
bufLen = Len(message)
' We initialize Winsock
If (WSAStartup(MAKEWORD(2,2), @wsaData) <> 0) Then
Beep: Print "Error: Winsock init"
Sleep
End
End If
' We create the socket
sendSocket = socket_(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
If sendSocket = INVALID_SOCKET Then
Beep: Print "Error: Net socket"
WSACleanup()
Sleep
End
End If
' We configure the server structure
recvAddr.sin_family = AF_INET
recvAddr.sin_port = htons(256)
recvAddr.sin_addr.s_addr = inet_addr("127.0.0.1")
' We send the message
Print "Trying: Net send"
iResult = sendto(sendSocket, @sendBuf(0), bufLen, 0, Cptr(sockaddr Ptr, @recvAddr), Sizeof(recvAddr))
If (iResult = SOCKET_ERROR) Then
Beep: Print "Error: Net send"
closesocket(sendSocket)
WSACleanup()
Sleep
End
Else
Print "number of bytes send:"; iResult
End If
iResult = closeSocket(sendSocket)
If (iResult < 0) Then
Beep: Print "Error: Close socket"
End If
'closesocket(sock)
WSACleanup()</syntaxhighlight>
=={{header|Frink}}==
<syntaxhighlight lang="frink">s = newJava["java.net.Socket", ["localhost", 256]]
w = new Writer[s.getOutputStream[]]
w.println["hello socket world"]
w.close[]</syntaxhighlight>
=={{header|Go}}==
<
import (
Line 484 ⟶ 569:
fmt.Println(err)
}
}</
{{out | Test with nc}}
<pre>
Line 494 ⟶ 579:
=={{header|Groovy}}==
<
s << "hello socket world"
s.close()</
=={{header|Haskell}}==
<
main = withSocketsDo $ sendTo "localhost" (PortNumber $ toEnum 256) "hello socket world"</
== Icon and Unicon ==
==={{header|Icon}}===
<
procedure main ()
hello("localhost", 1024)
Line 512 ⟶ 597:
procedure hello (host, port)
write(tconnect(host, port) | stop("unable to connect to", host, ":", port) , "hello socket world")
end</
Note: Socket support in native Icon is limited and requires the external helper function cfunc.
==={{header|Unicon}}===
Unicon integrated TCP/IP networking and messaging.
<
hello(arglist[2]|"",arglist[1])
end
Line 531 ⟶ 616:
else stop("Unable to connect to ",host,":",port)
return
end</
=={{header|IDL}}==
<
printf,unit,"hello socket world"
close, unit</
"Well-known" port numbers (under 1024 -- such as 256) can also be specified by name (in this case 'RAP').
Line 546 ⟶ 631:
<code>sdcheck</code> raises assertions if anything goes wrong:
<
socket =. >{.sdcheck sdsocket'' NB. Open a socket
host =. sdcheck sdgethostbyname 'localhost' NB. Resolve host
sdcheck sdconnect socket ; host ,< 256 NB. Create connection to port 256
sdcheck 'hello socket world' sdsend socket , 0 NB. Send msg</
=={{header|Java}}==
<
import java.net.*;
public class SocketSend {
Line 566 ⟶ 651:
sock.close();
}
}</
Encapsulating the <code>Socket</code>'s <code>OutputStream</code> in a <code>PrintStream</code> (for data) or <code>PrintWriter</code> (for text) may be easier in more complex programs for their auto-flush abilities, encoding management, and their overloaded <code>print</code> and <code>println</code> methods. The <code>write</code> method from the original <code>OutputStream</code> will still be available.
=={{header|Jsish}}==
<
function sockets() {
var sock = new Socket({client:true, port:256, noAsync:true, udp:true});
Line 583 ⟶ 668:
sockets() ==> undefined
=!EXPECTEND!=
*/</
{{out}}
Line 590 ⟶ 675:
=={{header|Julia}}==
<syntaxhighlight lang="julia">
socket = connect("localhost",256)
write(socket, "hello socket world")
close(socket)
</syntaxhighlight>
=={{header|Kotlin}}==
<
import java.net.Socket
Line 606 ⟶ 691:
it.outputStream.write("hello socket world".toByteArray())
}
}</
=={{header|Lasso}}==
<
#net->connect('127.0.0.1',256)
#net->dowithclose => {
#net->writestring('Hello World')
}</
=={{header|Lua}}==
{{libheader|LuaSocket}}
<
host, port = "127.0.0.1", 256
sid = socket.udp()
sid:sendto( "hello socket world", host, port )
sid:close()</
=={{header|MACRO-10}}==
<syntaxhighlight lang="macro-10">
TITLE SOCKET
COMMENT !
Socket Example ** PDP-10 Assembly Language (KJX 2022)
Assembler: MACRO-10 Operating System: TOPS-20 V7
On TOPS-20, TCP-connections are made by opening a special
file on the "TCP:" device (in this case "TCP:256"). Apart
from the funky filename, there is virtually no difference
between opening files on disk and creating TCP-connections
or endpoints, so we go through the usual sequence of GTJFN
(= get file-handle), OPENF (open file), finally followed
by CLOSF (close file).
!
SEARCH MONSYM,MACSYM ;Load symbolic names for syscalls.
.REQUIRE SYS:MACREL
STDAC. ;Define standard register names.
JFN: BLOCK 1 ;File handle for TCP connection.
TCPFN: ASCIZ /TCP:256/ ;TCP "filename"
STR: ASCIZ /Hello World!/ ;String to send.
STRLEN= <.-STR>*5 ;Length of string.
GO:: RESET% ;Initialize process.
;; Get a file-handle (JFN) for the TCP-connection:
MOVX T1,GJ%SHT ;Do "short" GTJFN% call.
HRROI T2,TCPFN ;TCP "filename" into T2.
GTJFN% ;Get file-handle.
ERJMPS ERROR ; Handle errors.
MOVEM T1,JFN ;Store JFN we got.
;; Open the "file":
HRRZ T1,JFN ;File-handle without flags into T1.
MOVX T2,FLD(8,OF%BSZ)!OF%RD!OF%WR ;8bit bytes, read+write.
OPENF% ;Open file.
ERJMPS ERROR ; Handle errors.
;; Write the string.
MOVE T1,JFN ;File-handle into T1.
HRROI T2,STR ;String-pointer into T2.
MOVEI T3,STRLEN ;Length of string into T3.
SOUT% ;Write string.
ERJMPS ERROR ; Handle errors.
;; Close file.
HRRZ T1,JFN ;Get file-handle into T1.
CLOSF% ;Close file.
ERJMPS ERROR ; Handle errors.
;; End program.
RESET% ;Reset, to release JFN.
HALTF% ;Halt program.
JRST GO ;Allow for continue-command.
;;
;; ERROR: Print standardized error-message by means of ERSTR.
;; This is similar to perror() in C.
;;
ERROR: MOVEI T1,.PRIOU ;Print on standard output.
MOVE T2,[.FHSLF,,-1] ;Own process, last error.
SETZ T3 ;No length-limit on error msg.
ERSTR% ;Print error-message.
JFCL ; Ignore errors from ERSTR%.
JFCL ; Dito.
RESET% ;Reset, to release JFN.
HALTF% ;Halt program.
JRST GO ;Allow for continue-command.
END GO
</syntaxhighlight>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
WriteString[socket, "hello socket world"];
Close[socket];</
=={{header|Myrddin}}==
<
const main = {
Line 641 ⟶ 811:
std.fatal("could not open fd: {}\n", err)
;;
}</
=={{header|Nanoquery}}==
<
p = new(Port)
p.connect("localhost", 256)
p.write("hello socket world")
p.close()</
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
Sockets in Neko
Tectonics:
Line 675 ⟶ 845:
socket_write(socket, "hello socket world");
socket_close(socket);</
For testing on port 256, root powers required
Line 689 ⟶ 859:
=={{header|Nemerle}}==
<
using System.Net.Sockets;
Line 701 ⟶ 871:
sock.Close();
}
}</
=={{header|NetRexx}}==
{{trans|Java}}
<<
options replace format comments java crossref symbols nobinary
import java.net.
Line 733 ⟶ 903:
end
return
</syntaxhighlight>
=={{header|NewLISP}}==
<
(set 'socket (net-connect "localhost" 256))
(net-send socket "hello socket world")
(net-close socket)
(exit)
</syntaxhighlight>
=={{header|Nim}}==
<
var s = newSocket()
s.connect("localhost", Port(256))
s.send("Hello Socket World")
s.close()</
=={{header|Objeck}}==
<
use Net;
Line 766 ⟶ 936:
}
}
</syntaxhighlight>
=={{header|Objective-C}}==
(untested)
<
// in some method
Line 789 ⟶ 959:
[oStream close];
}
}</
=={{header|OCaml}}==
<
let init_socket addr port =
Line 803 ⟶ 973:
let outchan = out_channel_of_descr sock in
let inchan = in_channel_of_descr sock in
(inchan, outchan)</
<
let ic, oc = init_socket "localhost" 256 in
output_string oc "hello socket world";
;;</
=={{header|Oz}}==
<
Socket = {New Open.socket init}
in
{Socket connect(port:256)}
{Socket write(vs:"hello socket world")}
{Socket close}</
=={{header|Pascal}}==
Line 823 ⟶ 993:
See also [https://rosettacode.org/wiki/Sockets#Delphi Delphi].
<
Uses
Line 878 ⟶ 1,048:
CloseSocket(TCP_Sock);
End.
</syntaxhighlight>
Variant without superfluous additions:
<
Uses
Line 909 ⟶ 1,079:
fpSend(TCP_Sock, PMessage, Message_Len, 0);
End.
</syntaxhighlight>
=={{header|Perl}}==
<
$host = gethostbyname('localhost');
Line 920 ⟶ 1,090:
connect(Socket_Handle, $in);
send(Socket_Handle, 'hello socket world', 0, $in);
close(Socket_Handle);</
Object oriented version.
<
$sock = Socket::Class->new(
Line 929 ⟶ 1,099:
) || die Socket::Class->error;
$sock->send('hello socket world');
$sock->free;</
=={{header|Phix}}==
Note this fails for me with "connection refused", just like the Go/Python/Ruby entries.
<!--<
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (sockets)</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">sockets</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 954 ⟶ 1,124:
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #7060A8;">WSACleanup</span><span style="color: #0000FF;">()</span>
<!--</
=={{header|PHP}}==
<
fputs($socket, 'hello socket world');
fclose($socket);</
=={{header|PicoLisp}}==
<
(out @ (prinl "hello socket world"))
(close @) )</
=={{header|Pike}}==
<
int main(){
Line 974 ⟶ 1,144:
con->write("hello socket world");
con->close();
}</
=={{header|Prolog}}==
This works with Gnu Prolog. Other implementations will have different predicates.
<
socket_connect(Socket, 'AF_INET'(localhost,Port), Input, Output),
write(Output, 'hello socket world'),
flush_output(Output),
close(Output),
close(Input).</
=={{header|PureBasic}}==
<
ConnectionID = OpenNetworkConnection("localhost", 256)
SendNetworkString(ConnectionID, "hello socket world")
CloseNetworkConnection(ConnectionID)</
=={{header|Python}}==
<syntaxhighlight lang
"""Connect to a socket. Requires Python >= 3.2."""
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect(("localhost", 256))
sock.sendall(b"hello socket world")
</syntaxhighlight>
{{out}}
This example output uses netcat (<code>nc</code>) to provide a socket to connect to. Some versions of netcat require the <code>-p</code> (port) flag to be used in combination with <code>-l</code> (listen mode), some treat the combination of <code>-l</code> and <code>-p</code> as an error, and some don't mind either way. On some systems, you can use <code>sudo netstat -tulpn | grep nc</code> to show what port netcat is actually listening on.
256 is a "well-known", reserved port number. Binding to well-known ports usually requires elevated permissions. Hence the use of <code>sudo</code> here.
<pre>
$ sudo nc -l -p 256 & python sock.py
[3] 10559
hello socket world[3] Done sudo nc -l -p 256
</pre>
=={{header|R}}==
<
s <- make.socket(port = 256)
write.socket(s, "hello socket world")
close.socket(s)
</syntaxhighlight>
=={{header|Racket}}==
<
(let-values ([(in out) (tcp-connect "localhost" 256)])
(display "hello socket world\n" out)
(close-output-port out))</
=={{header|Raku}}==
Line 1,015 ⟶ 1,199:
{{Works with|rakudo|2016.03}}
Will fail with a connect error if there is not a socket server of some kind available on the specified host and port.
<syntaxhighlight lang="raku"
my $port = 256;
my $client = IO::Socket::INET.new(:$host, :$port);
$client.print( 'hello socket world' );
$client.close;</
=={{header|Rhope}}==
{{works with|Rhope|alpha 1}}
<
|:
[New@Net Client["localhost",256]]Put String["hello socket world"]
:|</
The connection is automatically closed when the object is freed.
=={{header|Ring}}==
<
Load "guilib.ring"
Line 1,072 ⟶ 1,256:
waitforbyteswritten(300000)
close()
</syntaxhighlight>
=={{header|Ruby}}==
<
sock = TCPSocket.open("localhost", 256)
sock.write("hello socket world")
sock.close</
=={{header|Rust}}==
{{works with|Rust 1.0 stable}}
<
use std::net::TcpStream;
Line 1,092 ⟶ 1,276:
let _ = my_stream.write(b"hello socket world");
} // <- my_stream's drop function gets called, which closes the socket</
=={{header|Scala}}==
{{libheader|Scala}}
<
object sendSocketData {
Line 1,108 ⟶ 1,292:
sendData("localhost", "hello socket world")
}</
=={{header|Scheme}}==
{{works with|Guile|1.8.8}}{{works with|Chicken Scheme|4.6.0}}
<
(connect s AF_INET (inet-pton AF_INET "127.0.0.1") 256)
(display "hello socket world" s))</
=={{header|Seed7}}==
Line 1,121 ⟶ 1,305:
which returns a connected internet socket file at a port at localhost.
<
include "socket.s7i";
Line 1,131 ⟶ 1,315:
writeln(sock, "hello socket world");
close(sock);
end func;</
=={{header|SenseTalk}}==
<
set SocketID to "localhost:256"
open socket SocketID
write "Hello socket world!" to socket SocketID
close socket SocketID
</syntaxhighlight>
=={{header|Sidef}}==
<
var in = Socket.sockaddr_in(256, host);
var proto = Socket.getprotobyname('tcp');
Line 1,149 ⟶ 1,333:
sock.connect(in);
sock.send('hello socket world', 0, in);
sock.close;</
=={{header|Slate}}==
Line 1,155 ⟶ 1,339:
This uses fairly verbose and low level messages. This will probably be simplified in the future.
<
[ | addr stream |
addr: (Net SocketAddress newOn: '127.0.0.1:256').
Line 1,164 ⟶ 1,348:
stream flush
] ensure: [socket close]
] do.</
=={{header|Smalltalk}}==
Line 1,171 ⟶ 1,355:
This is taken from [http://sblinn.jottit.com/GNU_Smalltalk_SimpleEcho_TCP_Server here] with few modification to fit the task better.
<
Object subclass: #HelloSocket
Line 1,218 ⟶ 1,402:
Smalltalk at: #helloServer put: (HelloSocket port: 2560).
helloServer run.</
=={{header|Symsyn}}==
<
'127.0.0.1' $addr
connect $addr 256 sok
'hello socket world' [sok]
close sok
</syntaxhighlight>
=={{header|Standard ML}}==
<syntaxhighlight lang="text">val txt = Word8VectorSlice.full (Byte.stringToBytes "hello world" ) ;
val set = fn socket => fn ipnr => fn portnr => fn text =>
(
Line 1,236 ⟶ 1,420:
)
;
</syntaxhighlight>
call
set ( INetSock.TCP.socket () ) "127.0.0.1" 256 txt ;
=={{header|Tcl}}==
<
puts -nonewline $io "hello socket world"
close $io</
=={{header|Toka}}==
<
#! A simple abstraction layer that makes writing trivial servers easy
Line 1,258 ⟶ 1,442:
#! The actual server
[ " hello socket world" server.send ] 256 server.start</
=={{header|TXR}}==
<
(sock (open-socket server.family sock-stream)))
(sock-connect sock server)
(put-string "hello socket world"))</
=={{header|UNIX Shell}}==
Line 1,271 ⟶ 1,455:
{{libheader|nc}}
<
When the connection fails, <code>nc</code> exits 1. To see an error message, use <code>nc -v localhost 256</code>.
=={{header|Ursa}}==
<
p.connect "localhost" 256
out "hello socket world" endl p
p.close</
=={{header|Visual Basic .NET}}==
<
Imports System.IO
Imports System.Net.Sockets
Line 1,297 ⟶ 1,481:
tcp.Close()
End Sub
End Class</
=={{header|Wren}}==
{{trans|C}}
An embedded program so we can ask the C host to call the relevant library functions for us.
Although this worked when originally posted, the connection is now refused. The same applies to the C, Go, Phix, Python and Ruby entries and probably others.
<syntaxhighlight lang="wren">/* Sockets.wren */
var AF_UNSPEC = 0
Line 1,367 ⟶ 1,553:
pm = pm[slen..-1]
}
} else if (stat == -1) {
System.print("Connection refused.")
}
var status = Socket.close(sock)
Line 1,372 ⟶ 1,560:
}
addrInfoPtr.free()
}</
<br>
Now embed this script in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc Sockets.c -o Sockets -lwren -lm */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 1,575 ⟶ 1,765:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 1,591 ⟶ 1,781:
free(script);
return 0;
}</
{{out}}
<pre>
$ sudo nc -l 256 & ./Sockets
[23] 6074
Connection refused.
</pre>
=={{header|X86 Assembly}}==
{{works with|nasm|Linux}}
<
;using sockets on linux with the 0x80 inturrprets.
;
Line 1,766 ⟶ 1,955:
sport resb 2
buff resb 1024
</syntaxhighlight>
{{works with|MASM}}<br>
Operates in non-blocking mode.
<
.586
.model flat,stdcall
Line 1,916 ⟶ 2,105:
end start
</syntaxhighlight>
{{works with|MASM}}<br>
This example works in blocking mode.
<
.586
.model flat,stdcall
Line 2,039 ⟶ 2,228:
end start
</syntaxhighlight>
=={{header|X86-64 Assembly}}==
===UASM 2.52===
<
option casemap:none
option literals:on
Line 2,219 ⟶ 2,408:
end
</syntaxhighlight>
=={{header|zkl}}==
<
s.write("hello socket world"); //-->18
s.close();</
=={{header|Zsh}}==
<
ztcp localhost 256
print hello socket world >&$REPLY</
{{omit from|ACL2}}
|