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 » Socket functions calling order
Re: Socket functions calling order [message #13620 is a reply to message #13548] Thu, 17 January 2008 18:40 Go to previous messageGo to previous message
zaurus is currently offline  zaurus
Messages: 42
Registered: May 2006
Member
Hi captainc!

I was also playing around with network connections some time ago. Here my loop which is reading the data from the socket. It works ok for me.

void NetServTest::TimerLoop()
{	
	String sCommand;
	
	if(!m_Connection.IsOpen())
	{
		if(m_Socket.Accept(m_Connection, &m_ipaddr, true, 100))
			PromptOK("Accept.");
		Status = "OFF";
	}
	if(m_Connection.IsOpen())
	{
		Status = "ON";
		sCommand = m_Connection.Read(100);
		Output = sCommand;
		if(sCommand == "WHO")
			m_Connection.Write("It's me!");
		Sync();
	}
	SetTimeCallback(2000, THISBACK(TimerLoop));
}


I'm not doing anything to clear. I'm not a programming expert and cannot tell you what is really the correct way, but the above works for me.

I think in your code the sock1.Accept(sock1) is the problem. You should not accept the connection on the same socket on which you are listening.

Zaurus

[Updated on: Thu, 17 January 2008 18:46]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SocketEvent
Next Topic: MT Documentation
Goto Forum:
  


Current Time: Tue May 14 11:01:22 CEST 2024

Total time taken to generate the page: 0.01740 seconds