Socket issue

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Naga
Posts: 45
Joined: 2003-12-02 11:24
Location: Sweden

Socket issue

Post by Naga » 2006-03-01 02:16

Hi,

I'm working on upgrading LinuxDC++'s client to that of DC++ 0.687 and I have a problem.

In Socket::create() (Socket.cpp:76) there is a call to setBlocking(true).
If this call is enabled the client dies on startup since socket::read will return EWOULDBLOCK (-1) and this will be forwarded to SearchManager::onData() and here std::string will throw an error. If I comment this call everything "works" except that every time I would expect to se "No Slots Available" from a user I get "SocketException: Disconneted" in the transferview and "BufferedSocket: New command when already failed: 1" on std::out (BufferedSocket::checkEvents(), BufferedSocket:395). Is this a behavior that the windows client has too? Or does any of you know what is going on here?

/Thanks Naga
Thanks to all open source programmers!
They enable the rest of us to learn a lot!

gnipi
Posts: 4
Joined: 2006-09-06 10:56
Contact:

linux handles blocking a bit differently

Post by gnipi » 2006-09-06 11:18

setsockopt() call needed to set blocking / non-blocking sockets is different for
windows/linux. Afaik, setblocking(true) will make ::read call wait till data is available. It will not return -1 EWOULDBLOCK... search network code for checksocket() and wrap your network reads into it.

Locked