Results 1 to 6 of 6

Thread: Client/Server

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    8

    Client/Server

    Hello fellow coders,
    I have been a web developer for a number of years now and I am making the move over to form based applications. I am trying to do what I believe should be relatively simple, yet I have no idea where to start.

    At home I have a machine that family members tend to use P2P programs, which causes my online gaming to suffer with glitches.

    I want to create a server and client program.
    where the client app (on my laptop) consists of only one button, when the button is pressed I want the server app (my Desktop) to kill the P2P program.

    I already know how to kill/start the application in question.

    I have previously done something similar but I had used winsock (not in VS2010) and was a long time ago.

    So if possible I require help with the following.

    1) Sending a value/string from the client app
    2) receiving the value/string on the server app

    I was told to look into the system.net.sockets namespace, but I haven't found anything on the web or here that isn't a full project / over-engineered "Basic Tutorial" that helps to break this down


    Any help is appreciated.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Client/Server

    First off, I'm thoroughly amused by your description of the problem. It sounds like you want to kick off your family members when they get in the way of your gaming. That's a classic.

    Second, I would suggest that doing this using standard Client/Server will cause you great annoyance for nothing. You aren't sending much of anything. All you really need to send is a single byte. When that byte is received, the other end would take some action. This is an ideal place for UDP communication, especially across a LAN. Over in the .NET CodeBank you can find a UDP class I put together. It's kind of overkill for what you are doing, but you could easily take that and modify it to fit. The idea behind that is that both ends are running that class. In your case, you only really need the server to be running the class. It uses a background thread that just sits there and waits for somebody to send it something. That's light weight. Over on the client, you would strip out the small amount of that code that is used for sending, and use that to build a tiny app that sends a single byte. It wouldn't ever need to get anything back, though you could build a more robust solution where the server replied to the client to let it know that the message had been received.

    The thing about UDP is that there is no connection. Your client wouldn't even have to know that there WAS a server. You could just broadcast the message, and anybody listening on that port, including the server, would receive it....probably. Since there is no connection, there is always a chance that a particular packet didn't get through. TCP is like making a phone call, where the other person has to pick up for any communication to happen. UDP is like sending a text. You send it out, but it might get lost in transit, or the other person might not be paying attention (if the server was off, for instance).
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    8

    Re: Client/Server

    Haha, yes that's the basic idea! To kick them off when I want to optimize my connection.

    Thanks for taking the time to post a clear and concise reply, I shall take a look at your UDP class in the .NET code bank as you advised.

    I shall update you when I give it a try out and let you know how I get on.

    Once again thanks for your help, and pointing out a more suitable approach.

  4. #4
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Client/Server

    Another option would be to write a web service that is hosted on the desktop.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    8

    Re: Client/Server

    Hi Guys, Thanks for your replies!
    Unfortunately I haven't been able to get on with this task yet as I had an asthma attack and was in hospital for a week, I'm feeling better now and will update you when I have implemented a solution.

    Once again thanks for your help

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Client/Server

    Yeah, breathing is definitely more important than gaming.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width