Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - user

Pages: [1]
1
Network / Sample code for networking
« on: March 22, 2011, 01:19:25 pm »
Hi,
i wrote a code,in which one machine(A) sends "hi" to another machine(B).Now A sends the data successfully.But B does not receive it.I've bound the socket to the port but still,the status shows NotReady(at B).What is to be done?
Also, i need B to send back an ack to A.can u please help me out by showin a code on this.I need it for my project asap.

PS : I've seen the sample codes that are the tutorial,but donno y my code is not working.

2
Network / UDP packet not received by server
« on: February 20, 2011, 06:36:43 am »
Code: [Select]
unsigned short Port=4567;
DoClientUDP(hWnd,Port);

void DoClientUDP(HWND hwnd,unsigned short Port)
{
  sf::IPAddress ServerAddress;
  ServerAddress=sf::IPAddress::LocalHost;

  while (!ServerAddress.IsValid());
 
  sf::SocketUDP Client;
  unsigned short CPort=4323;

  Client.Bind(CPort);

   char Message[3] = "Hi";

    if (Client.Send(Message, sizeof(Message),ServerAddress, Port) != sf::Socket::Done)
          return;
   else
   {
     DoServerUDP(hwnd);
     Client.Close();
   }
}

void DoServerUDP(HWND hwnd)
{
  unsigned short Port=4567;
  sf::SocketUDP Server;

 char Buffer[200]="";
 std::size_t Received;

 sf::IPAddress ClientAddress=sf::IPAddress::LocalHost;
 
 unsigned short ClientPort;
 char Message[3]="";

 if (!Server.Bind(Port))
        return;
 Server.SetBlocking(false);

 sf::Socket::Status SocketStatus=sf::Socket::Done;
 SocketStatus=(Server.Receive(Message, sizeof(Message), Received, ClientAddress, ClientPort));

Server.Close();

}



This is my code. Now when i execute the statement(Server.Receive), the SocketStatus becomes NotReady.The client sends the message but the server does not receive it.What should be done???Please HELP!!!

Pages: [1]