Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[3997] Socket Programming in C# - Part 2

Last post 06-05-2007 5:07 AM by afas. 40 replies.
Page 1 of 3 (41 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [3997] Socket Programming in C# - Part 2

    This thread is for discussions of Socket Programming in C# - Part 2.

    • Post Points: 145
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 09-08-2003 6:43 AM In reply to

    • kike_lg
    • Not Ranked
    • Joined on 09-08-2003
    • New Member
    • Points 10

    Client problem

    Hi! I'm testing your code. If you launch several client applications, only the first connect with the server. Which is the problem? Perhaps you don't release socket server / client and the resource keep blocked.

    Grettings!
    • Post Points: 0
  • 09-17-2003 9:59 AM In reply to

    more than one client

    Firstly I would just like to say thanks for the great example code. Very helpful. I am now trying to have more than 1 client listen/communicate with the server. I am getting some very strange results though. Can anybody please give me some advice. I have altered the code on the server side to go back to "listening" after the first client connects. This works, but when the second client connects the first client gets kicked out (after a few seconds?) somehow.

    Look forward to any information.

    Thanks
    Jason
    • Post Points: 0
  • 09-22-2003 5:45 AM In reply to

    • stocholm
    • Not Ranked
    • Joined on 09-22-2003
    • New Member
    • Points 10

    Accessing recieved data as complete string

    First, let me thank you for the great article - it has proved really valuable for me in my current project.



    I am currently trying to extend the example to enable transfer of XML-data (or any data). However, I am not sure how to manipulate the recieved data as a complete string to parse using another function.

    Your example revieces a byte at a time and appends this to the content of a text box. Your example uses an "iterative" function to recieve each byte and then calls WaitForData() to wait for the next byte. But to be able to manipulate this data I need to somehow collect it in a string and when the data/command from the client has been received - do something like sending a answer back.

    The setup could be:

    Client sends command: "GetAmountInAccount"
    Server recieves this, checks the  and replyes: "You are broke"

    but how do I detect when the entire command from the client has been received?

    Thanks,



    • Post Points: 0
  • 09-29-2003 10:23 AM In reply to

    • hamzahwh
    • Not Ranked
    • Joined on 09-29-2003
    • New Member
    • Points 20
    hi .
    i want to ask if you can send me the program work ( multi client /server )
    can you send to me .

    my email : hamzahwh@yahoo.com
    • Post Points: 0
  • 09-29-2003 10:44 AM In reply to

    • hamzahwh
    • Not Ranked
    • Joined on 09-29-2003
    • New Member
    • Points 20
    hi .
    i want to ask if you can send me the program work ( multi client /server )
    can you send to me .

    my email : hamzahwh@yahoo.com
    • Post Points: 0
  • 09-29-2003 10:45 AM In reply to

    • hamzahwh
    • Not Ranked
    • Joined on 09-29-2003
    • New Member
    • Points 20
    hi .
    i want to ask if you can send me the program work ( multi client /server )
    can you send to me .

    my email : hamzahwh@yahoo.com
    • Post Points: 0
  • 10-13-2003 10:17 AM In reply to

    • sk-man
    • Not Ranked
    • Joined on 10-13-2003
    • New Member
    • Points 10
    Did any of you get the program to work with multiple clients?

    If so, how did you do it?
    • Post Points: 0
  • 10-13-2003 10:19 AM In reply to

    • sk-man
    • Not Ranked
    • Joined on 10-13-2003
    • New Member
    • Points 10

    close error

    I get an error when the client closes the connection, and then no new connections can be made. Does anybody have a solution

    Also. Did anybody get it to work with multiple clients?
    • Post Points: 0
  • 12-08-2003 5:07 PM In reply to

    Local IP

    If I have a system which has several local IP's  is there a way where I can designate which IP the connection is sent from?
    • Post Points: 0
  • 02-04-2004 1:43 PM In reply to

    • joejv_4
    • Not Ranked
    • Joined on 02-04-2004
    • New Member
    • Points 5

    Sample & Article

    I'm new to C#, and due to tome constaints on a project at work, had to learn as much as I could from books in order to test an SDK for a Pocket PC device.  Your sample and walk-through in the article were extremely helpful
    • Post Points: 0
  • 02-05-2004 1:40 AM In reply to

    • tucolino
    • Not Ranked
    • Joined on 02-05-2004
    • New Member
    • Points 5

    memory leak.

    everything looks fine. i liked the article except one bit. i ran the server and the client and on the client side, i believe it leaks memory. instead of taking the message from the server and putting it in the text box, i ignored it (to avoid the memory from the text stored). i opened the task manager and sent a bunch of messages to the client. the memory for the client kept increaing as long as i sent it more messages. any solutions to this?

    regards,

    tuco
    • Post Points: 0
  • 02-10-2004 2:50 AM In reply to

    • Rekcut
    • Not Ranked
    • Joined on 02-10-2004
    • New Member
    • Points 15

    Problems with Socket MultiThreading

    Hi all,

    I am currently trying to use the client code to simultaneously send icmp packets to several IPs from different threads. i.e. I have the client code as a class and I instantiate a new instance for each different IP. Within the class I implement an asynchronous delegate to run the client code, so that in the mean time I can return to the main  thread and implement a new instance  of the class and send a different icmp packet.

    Thus at any one time I have several instances of the client code running on different threads, waiting for icmp packets to be received on the OnDataReceived callback.

    My problem is that I am finding icmp reply packets from one thread in the receive databuffer of another thread. i.e.
    the CSocketPacket  object returned as a reference in "IAsyncResult asyn" is not coherent. In other words the data in theSockId.dataBuffer does not correspond to the theSockId.thisSocket socket.

    Is this happening because this code is not threadsafe?? or does anyone have any idea of how I can resolve this problem??

    Regards
    Rekkie
    • Post Points: 0
  • 02-11-2004 2:18 AM In reply to

    • Rekcut
    • Not Ranked
    • Joined on 02-10-2004
    • New Member
    • Points 15

    Problem solved

    Managed to figure out the problem with the help of Zane on the microsoft.public.dotnet.languages.csharp newsgroup. Basically it comes down to ping being a UDP packet that does not have a socket connection and so have to use .BeginReceiveFrom rather than BeginReceive.

    Ciao
    Rekcut
    • Post Points: 0
  • 02-19-2004 9:55 PM In reply to

    • mm_how
    • Not Ranked
    • Joined on 02-19-2004
    • New Member
    • Points 15

    Socket Exception

    Hi,
    I can run the server application successfully with port 8221 but I get an error when I changed the port number to 80, 8100 or others.

    Following is the exception:
    Only one usage of each socket address (protocol/network address/port) is normally permitted.

    Does anyone have any idea of how I can resolve this problem??
    • Post Points: 0
Page 1 of 3 (41 items) 1 2 3 Next >