How to solve connection reset error while reading/writing from socket in c++ -


My client and server are sending buffer messages to each other Client side:

  (Connect (sockfd, (struct sockaddr *) and serv_addr, Sizeof (serv_addr)) 
  • {perror ("add error"); Return (1); } Printf ("Getting buffer 1 from server side"); Bzero (buffer1,256); Int i = 0; While (i & lt; 5) {n = reading (Sakfide, buffer 1, size (buffer 1)); If (n & lt; 0) printf ("error socket% d in lane% d", n, sizeof (buffer 1)); N = write (sokfad, buff 2, size (buff 2)); If (n & lt; 0) printf ("Writing error in sort% d lan% d,", n, size (buff2)); Printf ("\ n Buffer 2 from the customer's side (Terminal type will not be)"); I ++; }
  • Server side:

      printf ("Sending server (domestic type) \ n"); While {(n = write (Newsockfdi, Buff 1, Size (Buff1)) gt; 0} {printf ("The query sent by the server% d:% hhx% hhx% hhX \ n", Count, Buff 1 [Counting] [0], Buff 1 [Calculation] [1], Buff 1 [Calculation] [2]); N = Read (Newsoffed, Rickfuff, Psychopharm (Recough)); Printf ("The server received the response:% hhx% hhx% hhX \ n", Ricuff [0], Rikfuff [1], Rickbuff [2]); Count ++; Count = count% 3; } If (n & lt; 0) {perror ("Error writing in socket"); Exit (1); }}  

    I received the output: server:

      ./ server server 9998 sending (DO terminal type) server sent query 1: FF FD 1 e server received response: FF FC 18 server transmitted query 2: FF FD 1D server received response: FF FC 18 server transmitted query 0: FF FD 18 server received response: FF FC 18 Server Sent query 1: FF FD1E server received response Done: FF FC 18 server sent Query 2: FF FD 1D server received response: FF FC 18 server sent query 0: FF FD 18 server received response: Written error in FF FC 18 socket: connection by peer Reset  

    Client side:

      ./ client 127.0.0.19998 buffer 2 from client side (terminal type will not be) buffer from client side buffer 2 server Receiving server (without exception I would like to send buffer 2 (without terminal type) from the client side, buffer 2 sent from the client side (not terminal type), buffer 2 from the client side (not the terminal type). Terminal type will not be) This is a Fter 5 buffer server to intercept the connection to the connection after I = 5, but the program gives the error of resetting the connection reset by the co-worker (I have something from the client side Tru B think). How should I fix this? Thanks in advance 


    Comments

    Popular posts from this blog

    winforms - C# Form - Property Change -

    javascript - amcharts makechart not working -

    java - Algorithm negotiation fail SSH in Jenkins -