IRC / std.sockets question

APott alanpotteiger at gmail.com
Mon Jan 13 19:42:28 PST 2014


Hello! I didn't really know if I should post here or not but I 
decided I should try. I recently started reading up on the IRC 
protocol and thought I would try to mess with it a bit and see if 
I could implement a server with a few features, just for fun. I'm 
already having trouble...
(I'm using the XChat client for testing)
If I've read the various specifications of the IRC protocol 
correctly the client should be the first one sending data to the 
server, either the pass message or the nick message (if a user). 
(If this is wrong stop right here and let me know)

With this assumption I was working with sockets and I'm failing 
to receive any data from the client, absolutely none. The 
connection is successful, the connection terminates when the 
socket is disposed of, I'm just getting absolutely no data from 
the client. Here's an example piece of code that would give this 
behavior:
```
Server.socket = new TcpSocket();
try {
     socket.bind(new InternetAddress(Server.port));
} catch (Exception e) {
     writeln(e.msg);
     return;
}
socket.listen(1);
		
Socket client = socket.accept();
byte[] buffer;
client.receive(buffer);
writeln(buffer);

client.shutdown(SocketShutdown.BOTH);
socket.close();

socket.shutdown(SocketShutdown.BOTH);
socket.close();
```
Any suggestions, corrections, or help with this is very much 
appreciated! I'm very curious on this subject. (I feel like I'm 
doing something really wrong or something... sometimes it takes 
more than 2 eyes to see something simple


More information about the Digitalmars-d mailing list