Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » non-blocking socket.Write("test string") crash on linux [BUG?]
non-blocking socket.Write("test string") crash on linux [BUG?] [message #11116] Mon, 20 August 2007 20:45 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I haven't dived deep into sockets but just trying to help lectus on the other thread found that with non-blocking
socket.Write("test string");

crashes my program at /Web/socket.cpp ~line 290
int Socket::Data::Write(const void *buf, int amount)
{
	RLOG("Socket::Data::Write: stil alive. amount= " << socket); //aris002
	int res = send(socket, (const char *)buf, amount, 0);  //DIES HERE!!!
	RLOG("Socket::Data::Write: DEAD alive???. amount= " << amount); //aris002
	if(res == 0 || res < 0 && GetLastError() != IS_BLOCKED)
		SetSockError("send");
	return res;
}

Is this a bug in upp or in my knowledge?

[Updated on: Mon, 20 August 2007 20:47]

Report message to a moderator

Re: non-blocking socket.Write("test string") crash on linux [BUG?] [message #11123 is a reply to message #11116] Mon, 20 August 2007 21:38 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
test case:
Re: non-blocking socket.Write("test string") crash on linux [BUG?] [message #11133 is a reply to message #11123] Tue, 21 August 2007 19:42 Go to previous messageGo to next message
rylek is currently offline  rylek
Messages: 79
Registered: November 2005
Member
Hello!

I've just looked at your P2PSocket example. I haven't yet checked if it really does crash under Linux, but I am not sure how the example is supposed to work. As 'sock' is a ServerSocket, what use is writing anything to it? I have always thought the only use of server sockets is to receive client conversations (via Accept); after Accepting a client socket you can read / write it as necessary, but I believe directly writing / reading a listening socket is a misuse of the socket protocol as such (and quite likely to crash a system which doesn't check the socket state in advance). We could put a flag there to mark the socket state and perhaps ASSERT that the socket being read / written is a ClientSocket or an Accepted socket. Or have I missed something important?

Regards

Tomas
Re: non-blocking socket.Write("test string") crash on linux [BUG?] [message #17918 is a reply to message #11133] Tue, 02 September 2008 22:48 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Is there an example please for how all this is meant to work? I notice that P2Psocket is very incomplete. A simple example showing a client and a server exchanging text strings after the user types something in the client app and presses "send" would be great.

If I figure it out in the meantime I'll post it myself.

Nick


EDIT: No worries, I found \Web\TServ\tserv.cpp - everything a person needs to know about writing a simple socket set is there Smile

[Updated on: Wed, 03 September 2008 00:33]

Report message to a moderator

Previous Topic: using gates but program lags
Next Topic: Mutex locks vs copy constructors
Goto Forum:
  


Current Time: Thu Mar 28 14:41:23 CET 2024

Total time taken to generate the page: 0.01358 seconds