Can't work with sockets
BCS
ao at pathlink.com
Mon May 7 07:51:56 PDT 2007
Reply to Niovol,
> I tried to make a program which can simply send messages and receive
> ones between 2 programs. I used DFL to make a form, buttons etc. I had
> 2 socket variables - remote_sock for server and sock for both server
> and client; i think the connection goes right, because of after
> executing remote_sock = sock.accept() remote_sock.remoteAddress()
> has a right address. But I can't send or receive any message. I deal
> with sock variable in the client program and remote_sock in the server
> program. To send I used send(void[]) method, to receive -
> receive(void[]). After sending I don't receive anything. Can anybody
> tell me where I was wrong? Are there some examples on using sockets
> with DFL?
>
if you are working under phobos this is what I would use
client side
Stream str = new SocketStream(new TcpSocket((new InternetAddress("whoever",
port)));
server side
auto soc = new TcpSocket();
soc.bind(new InternetAddress("whoever", port));
soc.listen(1);
Stream str = new SocketStream(soc.accept());
If you point those at each other you should get a pair of I/O streams that
can talk to each other.
(code not tested, working from memory)
More information about the Digitalmars-d
mailing list