[SFML 2.1 Network] Problem z działaniem komunikatora UDP
Ostatnio zmodyfikowano 2013-12-18 21:47
domin568 Temat założony przez niniejszego użytkownika |
» 2013-12-18 21:24:45 W cliencie na odbiorze mam : unsigned short port_receive = sf::Socket::AnyPort;
void receive_data() { if( socketUDP.receive( packet_receive, local_host, port_receive ) == sf::Socket::Done ) }
na serverze mam : sf::IpAddress local_host = "127.0.0.1"; unsigned short port = 54001;
void receive_data() { if( socketUDP.receive( packet_receive, local_host, port ) == sf::Socket::Done ) }
W cliencie wysyłam na : unsigned short port = 54001;
if( socketUDP.send( packet_send, local_host, port ) == sf::Socket::Done )
A w serverze wysyłam na : unsigned short port = 54001;
if( socketUDP.send( packet_send, local_host, port ) == sf::Socket::Done )
I niestety nadal nie działa, @DejaVu "Tym bardziej, że nadpisujesz sobie co i rusz wartości local_host i port przy odczycie danych." Nie za bardzo Cię rozumiem no bo w kodzie unsigned short port = 54001; sf::IpAddress local_host = sf::IpAddress::LocalHost;
int main() { ... }
Tworzę go tylko raz i używam tylko do odbierania i wysyłania danych, wysyłam je do funkcji odbierających i wysyłających ale jako argumenty, tak mi się wydaje że te funkcje ich nie zmieniają. Wysyłanie danych blokuje używanie tego samego ip do wysyłania i odbierania danych, nie mam pojęcia dlaczego, czy zmienna może być używana do dwóch funkcji współbieżnie ? |
|
DejaVu |
» 2013-12-18 21:47:38 Ty chyba nie czytasz ani tego co piszę, ani tego co jest napisane w dokumentacji... Status sf::UdpSocket::receive( void * data, std::size_t size, std::size_t & received, IpAddress & remoteAddress, unsigned short & remotePort ) Receive raw data from a remote peer.
In blocking mode, this function will wait until some bytes are actually received. Be careful to use a buffer which is large enough for the data that you intend to receive, if it is too small then an error will be returned and all the data will be lost.
Parameters data Pointer to the array to fill with the received bytes size Maximum number of bytes that can be received received This variable is filled with the actual number of bytes received remoteAddress Address of the peer that sent the data remotePort Port of the peer that sent the data Returns Status code See Also send
| http://translate.google.pl/#en/pl/remoteAddress%20-%09Address%20of%20the%20peer%20that%20sent%20the%20dataremoteAddress - adres uczestnika, który wysłał dane |
Nawet translator kropka w kropkę daje jasną informację 'co to jest'. Po to funkcje/metody mają REFERENCJE w argumentach, aby móc MODYFIKOWAĆ wartości zmiennych. Sądzę, że oficjalny kurs SFML-a również ma przykłady pokazujące jak POPRAWNIE odczytywać dane. |
|
1 2 « 3 » |