How to continous receive data from socket

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grandong
    New Member
    • Dec 2010
    • 4

    How to continous receive data from socket

    I tried to make an application to connect to the messenger server,So far i have this code:

    Code:
    Socket socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    socClient.Connect(new IPEndPoint(Dns.GetHostEntry(strHost).AddressList[0], intPort));
    
    //combine username and default packet.
    byte[] byLoginPhase1 = LoginProcess1(textBox1.Text);
    socClient.Send(byLoginPhase1);// send first packet to get respond key
    
    byte[] byBuffer1 = new byte[93];
    int intBuff1 = socClient.Receive(byBuffer1);
    
    byte[] byKey = new byte[8];
    for (int i = 85; i < byBuffer1.Length; i++)
    {
          byKey[i - 85] = byBuffer1[i];
    }// cut packet to get only the key
    
    // combine key and password and hashgen it
    byte[] byLoginPhase2 = LoginProcess2(byKey, textBox2.Text);
    socClient.Send(byLoginPhase2);// send hashgen + default packet
    
    byte[] byBuffer2 = new byte[1024];
    int intBuffer2 = socClient.Receive(byBuffer2);
    Now i successfully login to server, then the server should send a list of contacts etc, but how i can get them, how i can always receive packet the server send.
    thanks
Working...