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 » How to send msg to specific IP ?
How to send msg to specific IP ? [message #23105] Thu, 17 September 2009 10:45 Go to next message
MohamedMonem is currently offline  MohamedMonem
Messages: 7
Registered: March 2009
Promising Member
Hello all,

I made a simple server-client application and the server can accept many clients every time I extract the IP of each client, now how can I Send Msg to specific IP ?!!

Thanks in advance.
Re: How to send msg to specific IP ? [message #23114 is a reply to message #23105] Thu, 17 September 2009 17:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11700
Registered: November 2005
Ultimate Member
MohamedMonem wrote on Thu, 17 September 2009 04:45

Hello all,

I made a simple server-client application and the server can accept many clients every time I extract the IP of each client, now how can I Send Msg to specific IP ?!!

Thanks in advance.


Do you use 'accept' classics?
Re: How to send msg to specific IP ? [message #23119 is a reply to message #23114] Thu, 17 September 2009 19:57 Go to previous messageGo to next message
MohamedMonem is currently offline  MohamedMonem
Messages: 7
Registered: March 2009
Promising Member
luzr wrote on Thu, 17 September 2009 17:27

MohamedMonem wrote on Thu, 17 September 2009 04:45

Hello all,

I made a simple server-client application and the server can accept many clients every time I extract the IP of each client, now how can I Send Msg to specific IP ?!!

Thanks in advance.


Do you use 'accept' classics?


Could you explain more what is 'accept' classics ?

this is what i do
void App::AcceptClients()
{
	while(m_listener.IsOpen())
	{
		Socket TempSocket;
		dword ClientIp;
		if(!m_listener.IsError() && m_listener.Accept(TempSocket, &ClientIp))
		{
			String Ip = FormatIP(ClientIp);
			m_clients[Ip] = TempSocket;
		}
	}
}


m_clients is map<String, Socket, less<String> >

I tried to store socket for each client but this failed I get this error.

Quote:


rror C2558: class 'Upp::Socket' : no copy constructor available or c
opy constructor is declared 'explicit'



I think there are some way to send Msg to specific IP, I can easily store IPs.

thanks in advance.

[Updated on: Thu, 17 September 2009 19:58]

Report message to a moderator

Re: How to send msg to specific IP ? [message #23140 is a reply to message #23119] Fri, 18 September 2009 11:35 Go to previous message
mirek is currently offline  mirek
Messages: 11700
Registered: November 2005
Ultimate Member
MohamedMonem wrote on Thu, 17 September 2009 13:57

luzr wrote on Thu, 17 September 2009 17:27

MohamedMonem wrote on Thu, 17 September 2009 04:45

Hello all,

I made a simple server-client application and the server can accept many clients every time I extract the IP of each client, now how can I Send Msg to specific IP ?!!

Thanks in advance.


Do you use 'accept' classics?


Could you explain more what is 'accept' classics ?

this is what i do
void App::AcceptClients()
{
	while(m_listener.IsOpen())
	{
		Socket TempSocket;
		dword ClientIp;
		if(!m_listener.IsError() && m_listener.Accept(TempSocket, &ClientIp))
		{
			String Ip = FormatIP(ClientIp);
			m_clients[Ip] = TempSocket;
		}
	}
}


m_clients is map<String, Socket, less<String> >

I tried to store socket for each client but this failed I get this error.

Quote:


rror C2558: class 'Upp::Socket' : no copy constructor available or c
opy constructor is declared 'explicit'



I think there are some way to send Msg to specific IP, I can easily store IPs.

thanks in advance.



No, that is not how things work. You have to communicate with socket you get in Accept. At that moment, IP is not really interesting to you.

Now what you really need is to provide your 'target' socket in Accept. "One" can be really helpful there.

Now things get really nasty if you would need more than communication opened simultanously. In that case, you will have to choose some context/synchronization system and perhaps Select...
Previous Topic: Port giFT (a great but abandoned P2P project) to U++?
Next Topic: GuiLock Example broken
Goto Forum:
  


Current Time: Sat Feb 16 12:06:06 CET 2019

Total time taken to generate the page: 0.00615 seconds