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 - KingPenguinator

Pages: [1]
1
Hey, I saw post smiliar to this one, but it was a bit old, I didn't know if should ask there, or create a new one, so I just created a new one. I've seen the FAQ in the other post, i've tried the suggestions that I could do, but to no avail.

Anyway as the title suggests I can talk to the server when I use my local ip, but when I use my external Ip, or ask a friend to try on his pc it looks like it sends the packet, but the server doesn't receive it.

Client :
string id;
cout << "name: ";
cin >> id;

string ip;
cout << "Ip: ";
cin >> ip;

sf::IpAddress sender(ip) ;
sf::UdpSocket socket;
socket.setBlocking(false);

unsigned short port;
cout << "Port: ";
cin >> port;

socket.bind(port+1);
sf::Packet packet;

sf::Packet sendPacket;
sendPacket << "connection" << id;
socket.send(sendPacket, sender, port);

string connected;
socket.receive(packet, sender, port);
if(packet >> connected)
     if(connected=="done")  //Connection made
      //do stuff
 

Server :
sf::IpAddress sender;
unsigned short port;
socket.receive(packet, sender, port);
if(packet >> commandId)
{
      sf::Packet sendPacket;
      cout << commandId << endl;
      if(commandId=="connection")
      {
            string idStr;
            packet >> idStr;
            cout << idStr << " on " << sender.toString().c_str() << " has connected" << endl;
            //Do stuff
            sendPacket << "done";
            socket.send(sendPacket, sender, port);
       }
}

 

2
Network / Sending string to an e-mail adress
« on: June 18, 2014, 06:42:29 pm »
Hi, is it possible to use the network module in SFML to send an e-mail ?

Like "Hi, blalalalalalla" to example@something.com

3
Network / Trouble receiving ints in classes from packets
« on: June 04, 2014, 03:45:17 pm »
Hi

So I have this problem that has been bugging me these past few days, i've searched a fair bit, but to no avail.

When I do this:

//sockets and packets already declared

sf::Vector2i playerPos;

socket.receive(packet);
if(packet >> playerPos.x >> playerPos.y)
{
      player.setPosition(playerPos);
}

 
I'll get an overload error saying that the compiler doesn't know how to cast int to char*, I've heard somewhat that I need to make it explicit(I don't know how/where).

Any help would be appreciated, if you need more code, do say so

Pages: [1]