Anonymous user
Distributed programming: Difference between revisions
Updated to work with Nim 1.4: added types to parameters.
m (→{{header|C}}) |
(Updated to work with Nim 1.4: added types to parameters.) |
||
Line 893:
<lang nim>import os, nanomsg
proc sendMsg(s: cint, msg: string) =
echo "SENDING \"",msg,"\""
let bytes = s.send(msg.cstring, msg.len + 1, 0)
assert bytes == msg.len + 1
proc recvMsg(s: cint) =
var buf: cstring
let bytes = s.recv(addr buf, MSG, 0)
Line 905:
discard freemsg buf
proc sendRecv(s: cint, msg: string) =
var to: cint = 100
discard s.setSockOpt(SOL_SOCKET, RCVTIMEO, addr to, sizeof to)
|