I would like to create a server and client application that communicate via sockets using GIO. GSocketService and GSocketClient seem be perfect for this purpose but unfortunately I couldn't find some tutorial or example code (that a GLib, GIO,... newbie can understand). Does anybody know some good resources or can post example code here?
相关问题
- Multiple sockets for clients to connect to
- Drakma and Dexador both fails at USocket call whil
- difference between file descriptor and socket file
- Can we create a Silverlight Socket Server ONLY usi
- How do I get the client name from a socket in Java
相关文章
- socket() returns 0 in C client server application
- Passing extra metadata to a RequestHandler using p
- How do I get the external IP of a socket in Python
- Native hooking in Android Client
- Is zeroing out the “sockaddr_in” structure necessa
- Does the TCPServer + BaseRequestHandler in Python&
- Is it possible to convert between Socket and TcpCl
- Does send() always send whole buffer?
The callback from incoming should not block, from gio documentation: "The handler must initiate the handling of connection , but may not block; in essence, asynchronous operations must be used."
I had some issue with connection in the async version, it has to be referred by the user or the connection will close after the incoming callback returns.
A full example of a server that does not block, based on the example given before:
I finally managed to create both a simple server and client using glib and gio.
My server looks like this:
and this is the corresponding client:
Note though, that I am still new to glib, gio and even C, so double check my code before using it.