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

Author Topic: TCP Listening and Sending in the same time ?!?!?  (Read 3191 times)

0 Members and 1 Guest are viewing this topic.

kmanev073

  • Newbie
  • *
  • Posts: 2
    • View Profile
TCP Listening and Sending in the same time ?!?!?
« on: June 17, 2013, 04:42:29 pm »
Hello guys !
I am new to SFML and i really like it. Also this is my first post here ! Well... it is a question... :D So i want to to send packets and listen for packets in the same time on the same port and socket. Is this possible ? I use SFML 2 and i talk about TCP packets. Can some one help me ? I tried many ways but after i call tcppacket.connect so i can send a packet the port changed and i can listen on it... (i have to send and receive on the same port)

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: TCP Listening and Sending in the same time ?!?!?
« Reply #1 on: June 17, 2013, 04:57:28 pm »
That won't work (at least not exactly the way you defined it).

You don't have influence on the outgoing port, but you're able to define the incoming one.

For example, your server listens on port 12345 (don't use that port, bad idea) and a client connects. You're then able to use that connection to send and receive.

You can as well have two peer to peer clients, each one opening port 12345 and connecting to that port on the other client. This will work as well.

kmanev073

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: TCP Listening and Sending in the same time ?!?!?
« Reply #2 on: June 17, 2013, 05:25:50 pm »
well my problem is that first i have to send a packet  :-\

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: TCP Listening and Sending in the same time ?!?!?
« Reply #3 on: June 17, 2013, 08:01:34 pm »
well my problem is that first i have to send a packet  :-\

You should take a look at the networking tutorial.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor