Server question?

About Monkey 2 Forums Monkey 2 Programming Help Server question?

This topic contains 10 replies, has 4 voices, and was last updated by  SamFisher 1 year, 5 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #11269

    EdzUp
    Participant

    When looking at the echoserver.monkey2 file I see that the server doesnt have a stream is this an oversight?

    I ask as in all networking sometimes messages need to be sent to the server but from this the server doesnt have any way to receive them. I tried attaching a SocketStream to a socket that is listening but all I get is spammed with:
    socket_recv error! err=10057, msg=Unknown error, socket=1244, data=00e50184, size=4

    Does anyone have a more concise networking example maybe a simple chat system as the echoserver.monkey file doesnt actually show client/server systems as it appears that the client just spams its stream with data and gets it back again which is the effect I am getting now.

    #11274

    Mark Sibly
    Keymaster

    If you’re talking about TCP, a ‘listening’ server socket is not a stream – it is a ‘connection point’ for incoming connections (which are themselves streams). With TCP, you need to be connected before you can send/receive data so you can’t actually exchange any data with the ‘server’ which is there purely to establish the connections.

    With UDP you can talk to the ‘server’ (a ‘server’ doesn’t actually do much/anything) but it is unreliable and packets can arrive out of order so it’s not as easy to use as TCP.

    If you’re thinking about using something higher level, I was thinking about converting enet again which would be very easy to do. Would this be useful?

    http://enet.bespin.org/

    There is also raknet, which is much more complex and would likely take considerably longer to do fully:

    http://www.jenkinssoftware.com/raknet/manual/Doxygen/

    Both are very mature and well regarded.

    If you want to keep using sockets, I recommend looking at some socket tutorials first, eg:

    https://www.tutorialspoint.com/unix_sockets/

    A lof of these use threads to handle multiple connections, but the basic ideas are the same with fibers. Google for more etc…

    #11282

    EdzUp
    Participant

    If ENet had Max like functionality and ipv6 I would be very interested in that, from what I can gather though it’s still only ipv4. There is a bodge patch to make it use ipv6 but it’s reliability is questionable.

    If servers are just connection management then I will just reconfigure the code I have to make it work like that.

    One thing that puzzled me is I had two clients connected but both were receiving what they sent through the stream which is why I wondered if it was actually connected or was just bouncing back. I will dig deeper and try to adjust the echoserver code to see if I can get a example of the issue.

    #11285

    EdzUp
    Participant

    OK after giving this a lot of thought (yes my head hurts after all that lol) a way around it would be to give the server it’s own client  (id0) this means basically the connection server will be able to send messages to clients etc.

    It’s a nice theory and one I will now try to put into practice 🙂

    #11286

    Voidwalker
    Participant

    I know it’s OT but that’s the way the AGK guys handle it. When creating a server there, you will have client ID 0 instantly as well on the server side.

    #11287

    EdzUp
    Participant

    Thanks Voidwalker at least I know it’s how some other systems do it :).

    What I want to make is a easy to use robust network system for MX2 that way anything else will be easier when dealing with Internet/networking stuff.

    #11288

    Voidwalker
    Participant

    I will give this a try as well and will share my results. Maybe we can create some simple server client app for the bananas folder. 🙂

    #11289

    EdzUp
    Participant

    Good idea, we could make a simple chat program that could work with multiple clients. At least that way it could replace the echoserver.monkey file giving a better example 😀

    #11290

    Voidwalker
    Participant

    Yep, definitely. But I would wait for 1.1.08 because Mark changed quite a lot under the hood. Will see that I pull the github stuff and compile it by myself but the last time I tried (last week) it could not compile all modules because there were some breaking changes.

    #11291

    EdzUp
    Participant

    OK will wait for 1.1.0.8 🙂

    #11320

    SamFisher
    Participant

    Little late, but here a little Chat Server/Client App for 1.1.07 🙂

    Server.monkey2

    Client.monkey2

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.