Sockets issue
okibi
okibi at ratedo.com
Tue Jan 15 04:13:26 PST 2008
I'm a bit puzzled here. I'm trying to get my sockets working, but it only connects once. Here is my code:
server.d:
auto soc = new TcpSocket();
soc.bind(new InternetAddress("localhost", 10101));
soc.listen(10);
Stream str = new SocketStream(soc.accept());
while(true)
{
char[] line = str.readLine();
if (line !is null)
cmdOpen(line);
}
client.d:
Socket socket = new TcpSocket(new InternetAddress("localhost", 10101));
Stream stream = new SocketStream(socket);
stream.writeString(args[1]);
socket.close();
Can anyone point out what I'm doing wrong? The first connection works fine, but any connection afterwords fails (line IS null on second connection).
Thanks!
More information about the Digitalmars-d-learn
mailing list