Jump to content

Sockets: Difference between revisions

681 bytes added ,  3 years ago
Line 835:
$sock->send('hello socket world');
$sock->free;</lang>
 
=={{header|Phix}}==
Note this fails for me with "connection refused", just like the Go/Python/Ruby entries.
<lang Phix>include builtins\sockets.e
constant msg = "hello socket world"
atom sock = socket(AF_INET, SOCK_STREAM)
if sock>=0 then
atom pSockAddr = sockaddr_in(AF_INET, "localhost", 256)
integer res = connect(sock, pSockAddr)
if res=SOCKET_ERROR then
crash("connect (%v)",{get_socket_error()})
end if
string pm = msg
while true do
integer len = length(pm),
slen = send(sock, pm)
if slen<0 or slen=len then exit end if
pm = pm[slen+1..$]
end while
closesocket(sock)
end if
WSACleanup()</lang>
 
=={{header|PHP}}==
7,806

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.