Skip to main content
↑
↓
Spherical forums
Community for the
Sphere game engine
New?
Contact Us
to register an account!
1 Hour
1 Day
1 Week
1 Month
Forever
Community
Help
Search
Recent Posts
Log in
Contact Us
News
Spherical
Facebook
-
Twitter
-
Discord chat
New?
Contact us
to register an account!
Sphere Development
Sphere Support
How do you use sockets?
1
Print
Topic: How do you use sockets?
(Read 4161 times)
previous topic
-
next topic
0 Members and 1 Guest are viewing this topic.
Cape Abel
Logged
Guest
How do you use sockets?
April 11, 2014, 07:41:33 am
The wiki isn't very clear. The forum search I did didn't give any clear examples. I tried using them on my own but although I can get .isConnected() to return true, I can't get anything from .read(). Does anyone have any working examples I could look at?
Flying Jester
Legendary Poster
Posts: 1,161
Logged
TurboSphere Developer
Re: How do you use sockets?
Reply #1
–
April 11, 2014, 01:50:49 pm
The sockets work like actual network sockets. You can see a couple simple examples
on archives of the old wiki.
Can we see what you are trying to do? Using sockets is pretty intermediate programming.
You need to either act like a server and listen on a port, or a client and call connect. In either case, you will need another service running on the other side, trying to do the opposite that you are.
Read() won't, for instance, read websites. You need to do an HTTP request.
The key here is that these are just like full BSD sockets. They don't buy you anything on their own but raw data transfer. You would need to implement whatever protocol you want to use (http, ftp, irc, something custom, something else entirely) on your own.
If you really want to do this, I really, really recommend trying to make something like an IRC client first. IRC is nice because it is a very simple and well documented communication standard, is a pretty good example of how client-server communications work (at least conceptually), and has tangible results.
Last Edit
: April 11, 2014, 07:31:04 pm by Flying Jester
Learn some history?
The Flying Jester's Blog of Sorts
Rahkiin
Medium Poster
Posts: 152
Mac OSX Developer
Logged
Re: How do you use sockets?
Reply #2
–
April 14, 2014, 12:30:46 pm
I do like to point out that HTTP is easier than IRC. You just connect, write the HTTP GET header and then read the response
Just some string processing. But eh.
Good luck!
Pegasus API:
https://github.com/sphere-group/pegasus
Delphinus:
https://github.com/joskuijpers/delphinus
1
Print
Sphere Development
Sphere Support
How do you use sockets?