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

Author Topic: UDP and send AND receiving?  (Read 2426 times)

0 Members and 1 Guest are viewing this topic.

Fouf

  • Newbie
  • *
  • Posts: 23
    • View Profile
UDP and send AND receiving?
« on: June 28, 2011, 01:51:35 am »
I am trying to receive and send with a UDP socket, but it never works.. I can either just send, or receive. I have tried non blocking, I have tried more than one thread.. It just seems that I can only send and receive if I use 2 sockets..? Any input on this? :c

if I have a loop like so:

Code: [Select]
while(running)
{
     receive();
     sendAPacket();
}

and receive is like so:
Code: [Select]

sf::Socket::Status socketStatus = recvSocket.Receive(recvPacket, serverIP, port);
if(socketStatus == sf::Socket::Done)
{
if(recvPacket >> receivePacket)
{
                }
         }
}

No packets will be received by the server, whether the socket is blocking or not....... if I comment out receive, the server gets all packets.. but the client no longer can receive...

What is happening!??!

Should I switch to something else? I really enjoy the whole packet thing though :|!
- Fouf

Fouf

  • Newbie
  • *
  • Posts: 23
    • View Profile
UDP and send AND receiving?
« Reply #1 on: June 30, 2011, 09:10:24 pm »
Yeah.. if I have it set to non blocking, any packets sent BEFORE a single socket.receive is called will make it. But any after do not make it.. I am so confused .. any help please, as I wish to continue work on my project :c

EDIT:
I now have it working... I was passing a filled IPAddress and port to receive.. this really threw me off for a while :C oh well all good now. Thanks.
- Fouf