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

Author Topic: What can packets send?  (Read 3599 times)

0 Members and 1 Guest are viewing this topic.

Superdude

  • Newbie
  • *
  • Posts: 4
    • View Profile
What can packets send?
« on: September 22, 2013, 09:06:28 am »
I am making a chat program and I am wondering if I have to send strings, or if I can send a struct. (Probably not, since the receiving end is not always a C++ program.

Can you give me the details?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: What can packets send?
« Reply #1 on: September 22, 2013, 09:38:15 am »
Read the packet tutorial: http://sfml-dev.org/tutorials/2.1/network-packet.php

If you're trying to talk to someone else's code then things get a lot more complicated, but if you're just making a chat program, it seems like your program would only ever be talking to copies of itself, so I don't see the problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: What can packets send?
« Reply #2 on: September 22, 2013, 11:09:31 am »
sf::Packet has its own internal protocol, you can't receive and decode a SFML packet in a non-SFML program.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: What can packets send?
« Reply #3 on: September 22, 2013, 03:31:02 pm »
sf::Packet has its own internal protocol, you can't receive and decode a SFML packet in a non-SFML program.
Well you can, you just have to reimplement the protocol again. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Superdude

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: What can packets send?
« Reply #4 on: September 22, 2013, 03:49:00 pm »
Hmmm... So I can send a struct?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: What can packets send?
« Reply #5 on: September 22, 2013, 04:00:18 pm »
You can send anything, but it's also your job to convert the data into bytes to transfer it and translate it back again. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: What can packets send?
« Reply #6 on: September 22, 2013, 07:02:25 pm »
Quote
Well you can, you just have to reimplement the protocol again.
... which I can change at any time, since it's not part of the public API ;D

Quote
Hmmm... So I can send a struct?
Have you read the tutorial? There is an example for exactly what you are asking here...
Laurent Gomila - SFML developer

Superdude

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: What can packets send?
« Reply #7 on: September 23, 2013, 08:45:48 pm »
Yes, I have now  :D

So, what you are saying, is that I should overload the << and >> operators for my struct?
Ok, will do!

Thanx alot!


Solved

 

anything