I'm going to see if I can build a simple IRC server in Nim (OSS of course), and wondering if anyone could point me to an example of using sockets in Nim.
Or, if someone would be kind enough to write up a 10 line example of opening a socket for listen, and responding to a client.
I've written an IRC client in LiveCode and done some other socket stuff before, but most socket interaction was abstracted away by the language/engine.
I have not!
At a glance, that looks exactly like what I need, thanks dom!
Whatever I end up with, I'll toss it up on Github
Figured it out. Problem seems to have been with puttytel.
I set Telnet negotiation mode from Active to Passive and didn't get the funky characters.
I have run into a problem I didn't create.
The example doesn't contain any cleanup, and crashes as soon as any client disconnects.
I'm guessing it's because it's trying to send to a client that doesn't exist.
@Daimon: which version of Nim your are using, devel?
@lunkik: keep recv data from socket into a buffer (then join them or do whatever you want) until you get "" (empty string)
Can we not resurrect old threads like this please? If you have a question then feel free to create a new thread.
Why do you need to know how many bytes you can read? You should be reading in a loop anyway, until you receive "" like @rgv151 said.
Hope this will help you....
http://csharp.net-informations.com/communications/csharp-socket-programming.htm
Balmer