Results 1 to 5 of 5

Thread: C# Sockets

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Question C# Sockets

    Hi Guys,

    I have a program that is meant to connect to a game server over TCP port 8080. The connection is all good, and as far as I can tell I am able to send packets. What I need to know is how to Receive every packet the game server sends back. Keep in mind it is sending well over 30packets a second back. Would I just write a while(true) loop to receive or is there something im missing?

    Thanks,

    Josh

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# Sockets

    Depending on the circumstances, you might also consider using asynchronous methods.

    Also, don't use While True when you can just use Do.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: C# Sockets

    Thanks I think I will end up making a Packet handling function and then run it on a separate thread. I guess I could just use a Do (thanks I forgot that while(true)'s are a bit dodgy) loop checking if socket.Receive != 0 and then call A seperate funtion to do the checking, and if it does = 0 (no packet to receive) then just return 0!

    Thanks though

    -Josh

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2010
    Posts
    121

    Re: C# Sockets

    Ok... This has nothing to do with sockets... but since you will most likely check this thread again since I replied, I'll ask it here. I need a pretty simple but effective activation system for it... I found this page- http://www.codeproject.com/KB/securi...ctivation.aspx. What do you think? And if it's enough for simply limiting usage to one user or more, could you please head me on the right track as that page isn't very helpful -.-

    -Josh

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# Sockets

    Quote Originally Posted by jmcilhinney View Post
    Also, don't use While True when you can just use Do.
    Oops! Forgot I was in C#. Doesn't apply.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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