Sockets: Difference between revisions
Content deleted Content added
m Unicon/Icon consistency 2 |
m Unicon/Icon consistency 2 |
||
Line 276:
main = withSocketsDo $ sendTo "localhost" (PortNumber $ toEnum 256) "hello socket world"</lang>
==
==={{header|Icon}}===
<lang icon>link cfunc
procedure main ()
hello("localhost", 1024)
end
procedure hello (host, port)
write(tconnect(host, port) | stop("unable to connect to", host, ":", port) , "hello socket world")
end</lang>
Note: Socket support in native Icon is limited and requires the external helper function cfunc.
==={{header|Unicon}}===
Unicon integrated TCP/IP networking and messaging.
<lang unicon>procedure main(arglist) #: usage socket port hostname or socket port
hello(arglist[2]|"",arglist[1])
end
procedure hello(host,port)
local s
/host := ""
host ||:= ":"
host ||:= 0 < 65536 > port | runerr(103,port)
if s := open(host,"n") then {
write(s, "hello socket world.")
close(s)
}
else stop("Unable to connect to ",host,":",port)
return
end</lang>
=={{header|IDL}}==
|