TCP Network Server / Client
Monkey Forums/Monkey Programming/TCP Network Server / Client
| ||
Sorry sorry... I know this has been done to death here, but I simply can't get my head around it :( I've checked out the udpechoserver code, and I can't seem to figure out how to make even a simple connection from one Monkey App to another one running a server. I simply need to have a client connect to the server, exchange information and that's it. UDP so I can have many connections without long delays, although it isn't time-critical I suppose. I know it's probably asking a lot, but could I please get a little help? :) Oh, and I need to have it on GFWL, Android and iOS if possible - I think that's easy enough using BRL... |
| ||
Get example, cut server side code to one app, client code to another. Change IP address/ Port settings and start debug. :) |
| ||
So the server only code is this? ? |
| ||
|
| ||
Hmm I'm getting there, just trying to figure out how to reply to client data received.... Thanks for the help :) |
| ||
(done it :D Now to write the next million lines of code... :| ) |
| ||
Ok, if anyone could shed some light on how to trap a client disconnect I'd be eternally grateful... Getting TRANS FAILED: Error executing 'MonkeyGame', return code=-1073741819 as an error as soon as a client drops ungracefully. Tried various Try/Catch exceptions, but none seem to work. I'm using the TCP code instead of UDP as it seems easier to work with (although that might just be me), so I'm using SendAsync/ReceiveAsync stuff. If I close the client gracefully with a _socket.Close() then all is good. |
| ||
Never mind... caffeine prevails once again.. damn this network code is fiddly! |
| ||
Kaltern -- can you share with what you've got so far :) -- thanks |
| ||
@nikoniko -- thanks for your post , your last code post looks to be the server side app but I do not see a complete code app for the client or am I missing it Thanks, Rod |
| ||
Kaltern wrote: how to trap a client disconnect No pings from client - client is disconnected navyRod wrote: but I do not see a complete code app for the client For client remove line _server=New UdpEchoServer( 12344 ) (and/or server's class definition). If you will build 2way communication based on UDP you have to implement server and client in an one application (as the udp echo example). |
| ||
Bear in mind I am 100% new to Monkey, so this code is guaranteed to be not very useful... Client Code Now, like I said, I am reasonably good with VB, and I used to use Blitz3D, and also I've never had to deal with TCP networking before, so this code may be totally useless. It seems to work more or less, although I am struggling to handle many datapackets at once on the client side - but that's probably down to the parsing code I've written. If anyone finds any problems with the above code... please be nice? lol |