|
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
1. WxWindows sockets #2323 Posted by: 2003-06-18 02:23:17 |
I'm not sure is this right place for this question, but does anyone know how to use wxWindow sockets? I'm familiar with "normal" socket programming, but wxWindows sockets are little bit different.
I have tried browse wxWindows manual and I have found socket section there, but it doesn't help much. And I haven't found code example anywhere.
Is there any tutorial or code which could clear things out? |
2. Re: WxWindows sockets #2368 Posted by: 2003-07-07 18:21:53 |
"And I haven't found code example anywhere." Sure there is :)
It's under samples/sockets (a little client server example). You may also have a look at samples/IPC, which too uses a server client model. I confess, the docs on sockets is somewhat too short. Even if you know about sockets it sometimes won't help much. Currently I'm getting some weird errors while programming a little chat server and client. At home it works just fine (gcc 3.2, wx 2.4.1) but here at college (gcc 2.95, wx 2.4.0) the client sometimes segfaults for reasons beyond my knowledge :) Anyway, the socket classes work...
upcase |
3. Re: WxWindows sockets #2375 Posted by: 2003-07-07 23:49:52 |
upcase wrote:
> I confess, the docs on sockets is somewhat too short. Even if > you know about sockets it sometimes won't help much. Currently > I'm getting some weird errors while programming a little chat > server and client. At home it works just fine (gcc 3.2, wx > 2.4.1) but here at college (gcc 2.95, wx 2.4.0) the client > sometimes segfaults for reasons beyond my knowledge :) > Anyway, the socket classes work... > > upcase
Does it by chance have anything to do with this: http://www.wxwindows.org/faqgtk.htm#redhat?
404 |
4. Re: WxWindows sockets #2378 Posted by: 2003-07-08 16:01:48 |
Thanks for your reply, but no, that's not the prob. Firstly I'm on Windows and secondly the connection is just fine. I can start the server, connect one or more clients, messages get send and distributed to all clients... But for some reason I cannot explain a client will crash while trying to send a message. The message actually IS send and is recieved by all other clients. Still the sending client crashes... I guess I'll rewrite server and client sometime, because it actually started off as a simple echo server/client to test socket programming in wx, but then I bloated up the code and it's pretty hard to read now :)
upcase |
5. Re: WxWindows sockets #2381 Posted by: 2003-07-08 22:04:41 |
So you have a server that transmits logins to all other clients? So when a client connects to the server, the server tells all the other clients, "hey, client #n just logged in? That sounds like the same thing I'm about to write, just as soon as I figure what is up with my wxNotebook not appearing. I'd be interested to know how it works out.
Two things I can think of but purely speculation. Are all the objects you are using properly initialized? One thing I found that helped me that I noticed in other code is assigning NULL to each object before initalization just to be safe, ie. (wxThingy *) m_thingy = NULL; So if the object isn't created properly due to memory errors, timeout errors, etc, I get assertions regarding invalid objects and the like.
The second thing would be to question are you handling the message that the new client gets? In other words, the client logs in, the server tells the client that it logged in just like it tells all the other clients, and somehow that message is following up the works?
Again, purely speculation on my part but maybe there is a tidbit if intelligence in there :)
404 |
6. Re: WxWindows sockets #2383 Posted by: 2003-07-09 14:20:15 |
Hi again!
Yep, that's more or less what I'm trying to do... The process is like the following: 1. Start the server (pretty obvious :)) 2. Start the client (specifiying the hostname of the server, the portnumber and nickname) 3. On connection the server checks if there's allready a nickname asigned to another client -> if yes, it refuses connection. 4. The server distributes information that another client has joined the chat (yep, the original client receives this one too) 5. On sending messages the server only recieves the message and passes it on to all other clients.
The server and clients handle some kind of flags to distinguish between "normal" messages and special ones (for the server, like that the client will log out..). The flags get send before anything else. On message sending first the flag, then the length of the message and then the actual message get send. The wierd thing is that everything seems to work just fine... The login never failed or crashed. Flags get send and interpreted correctly, so does the length of the messages and the message itself. For some reason it sometimes works and then again after some time the client crashes when sending a normal message. Problem is that the message actually IS send and recieved by server and other clients, so I guess the problem is the sending client recieving it's own message. I tried modifying the server so that it would not send the message back to the sending client, but that didn't solve the problem either. I thought that maybe there was a problem that the sended message wasn't terminated correctly and I'll add a '\0' at the end of each message... The real problem is that this bug is so random that you just can't debug it :) As I said I guess I'll rewrite the important parts again, hoping that I missed something...
upcase PS: Yep, I initialized the pointers :) |
7. Re: WxWindows sockets #2389 Posted by: 2003-07-12 02:49:46 |
upcase wrote:
> Hi again! > > Yep, that's more or less what I'm trying to do... > The process is like the following: > 1. Start the server (pretty obvious :)) [..snip..] > 5. On sending messages the server only recieves the message and > passes it on to all other clients
Yep, that is exactly what I have on my TODO list. My thinking is that I'll have clients with one or more clients being other servers sharing the information they've received from their own clients. Eventually the goal is to create a distributed gaming server.
> The real problem is that this bug is so random that you just > can't debug it :)
I hate those :P I had a bug similar to that yesterday as a matter of fact where the program would crash if a child window was open when it closed. Only happened once in a great while but I did what you mentioned before and shuffled my code around and so far it seems to have gone away.
> PS: Yep, I initialized the pointers :)
Good :)
404 |
8. Re: WxWindows sockets #2448 Posted by: 2003-08-08 02:48:10 |
I haven't been here recently. Anyway now I found code example.
Thanks a lot! |
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |