1
Network / Socket Unresponsive?
« on: August 13, 2011, 11:10:58 pm »
Thanks Laurent ^_^
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.
if (Listen.Receive(Buffer2, sizeof(Buffer2),Received,Address1,portn) != sf::Socket::Done)
{
std::cout<<"Error"<<std::endl;
}
else if (Listen.Receive(Buffer2, sizeof(Buffer2),Received,Address1,portn) == sf::Socket::Done)
{
std::cout<<"Message From:"<<std::endl;
std::cout<<Address1<<":"<<Listen.GetLocalPort()<<std::endl;
std::cout<<Buffer2<<std::endl;
}
else
std::cout<<"Unknown Problem";
if (Listen.Receive(/*etc.*/) == sf::Socket::Error)
#include <SFML/Network.hpp>
#include <iostream>
int main()
{
unsigned short Port;
sf::IpAddress Address1 = sf::IpAddress::GetPublicAddress();
sf::UdpSocket Socket;
char Buffer[] = "Hi guys!";
std::cin>>Port;
if (Socket.Send(Buffer, sizeof(Buffer), Address2, Port) != sf::Socket::Done)
{
std::cout<<"Socket (Send) Failed to Send"<<std::endl;
}
else if (Socket.Send(Buffer, sizeof(Buffer), Address1, Port) == sf::Socket::Done)
{
std::cout<<"Message sent"<<std::endl;
}
return 0;
}
#include <SFML/Network.hpp>
#include <iostream>
int main()
{
unsigned short Port;
sf::IpAddress Address1 = sf::IpAddress::GetPublicAddress();
std::cin>>Port;
sf::UdpSocket Listen;
if (Listen.Bind(Port) == sf::Socket::Done)
{
std::cout<<"Successfully bound to Port: "<<Port<<std::endl;
}
unsigned short portn = Listen.GetLocalPort();
std::size_t Received;
char Buffer2[128];
if (Listen.Receive(Buffer2, sizeof(Buffer2),Received,Address1,portn) != sf::Socket::Done)
{
std::cout<<"Error"<<std::endl;
}
else if (Listen.Receive(Buffer2, sizeof(Buffer2),Received,Address1,portn) == sf::Socket::Done)
{
std::cout<<"Message From:"<<std::endl;
std::cout<<Address1<<":"<<Listen.GetLocalPort()<<std::endl;
std::cout<<Buffer2<<std::endl;
}
else
std::cout<<"Unknown Problem";
return 0;
}
LoadResource("\\system\\sfml-window-2.dll");
LoadResource("\\system\\sfml-window-d-2.dll");
Maybe you should be sober while programming? After all it's a brain activity.
no worky. What's wrong? Be back latez.
Styles don't need to equal anything, they just are.Code: [Select]sf::RenderWindow Window(Program, "My Program", sf::Style::Resize, 0);
Try out all the different styles by compiling and changing the style between Resize and the other options, you'll quickly see how it works, and what the different options do.
sf::RenderWindow Window(Program, "My Program", sf::Style::Resize = 0, 0);