Socket error 10053(An established connection was aborted by the software in your host machine.)

I make a socket server using js and send message from a client running on
windows xp. But I get a 10053 error, I don't what's wrong with my client
code.
I use the same client code talking to a server writing with winsock is OK.
I use the demo code from
http://lxr.mozilla.org/mozilla/source/netwerk/test/TestServ.js and make a
little change below


consumeInput: function(input)
    {
      /* use nsIScriptableInputStream to consume all of the data on the
stream */
      var str = "";

      var sin = Components.classes["@mozilla.org/scriptableinputstream;1"]
                          .createInstance(nsIScriptableInputStream);
      sin.init(input);

      /* discard all data */
      while (sin.available() > 0)
        str +=sin.read(512);

      return str; // store the string send from client and send it back
later
    }



/* this function is called when we receive a new connection */
    onSocketAccepted: function(serverSocket, clientSocket)
    {
      dump(">>> accepted connection on
"+clientSocket.host+":"+clientSocket.port+"\n");

      var input = clientSocket.openInputStream(nsITransport.OPEN_BLOCKING,
0, 0);
      var output = clientSocket.openOutputStream(nsITransport.OPEN_BLOCKING,
0, 0);

      var str = this.consumeInput(input);

      //const fixedResponse =
      //  "HTTP/1.0 200 OK\r\nContent-Type:
text/plain\r\n\r\nFooooopy!!\r\n";
      //var response = fixedResponse + "\r\n" + new Date().toString() +
"\r\n";
      //var n = output.write(response, response.length);
      //dump(">>> wrote "+n+" bytes\n");

      output.write(str, str.length); // send the response back

      input.close();
      output.close();
    },



/// my client server code under windows xp compiled by vc6

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <winsock2.h>

int main(int argc, char* argv[])
{
     // Initialize Winsock
     WSADATA wsaData;
  DWORD errno;

     int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);

     if (NO_ERROR != nResult)
     {
          printf("\nError occurred while executing WSAStartup().");
          return 1; //error
     }
     else
     {
          printf("\nWSAStartup() successful.");
     }

     SOCKET Socket;
     int nPortNo;
     struct sockaddr_in ServerAddress;
     struct hostent *Server;

     char szBuffer[256];

     //Port number will be supplied as a commandline argument
     nPortNo = 4444;

     //Create a socket
     Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

     if (INVALID_SOCKET == Socket)
     {
          printf("\nError occurred while opening socket: %ld.",
WSAGetLastError());
          goto error;
     }
     else
     {
          printf("\nsocket() successful.");
     }

     //Server name will be supplied as a commandline argument
     //Get the server details
     Server = gethostbyname("localhost");

     if (Server == NULL)
     {
          closesocket(Socket);
          printf("\nError occurred no such host.");
          goto error;
     }
     else
     {
          printf("\ngethostbyname() successful.");
     }

     //Cleanup and Init with 0 the ServerAddress
     ZeroMemory((char *) &ServerAddress, sizeof(ServerAddress));

     ServerAddress.sin_family = AF_INET;

     //Assign the information received from gethostbyname()
     CopyMemory((char *)&ServerAddress.sin_addr.s_addr,
          (char *)Server->h_addr,
          Server->h_length);

     ServerAddress.sin_port = htons(nPortNo); //comes from commandline

     //Establish connection with the server
     if (SOCKET_ERROR == connect(Socket, reinterpret_cast<const struct
sockaddr *>(&ServerAddress),sizeof(ServerAddress)))
     {
          closesocket(Socket);

          printf("\nError occurred while connecting.");
          goto error;
     }
     else
     {
          printf("\nconnect() successful.");
     }

     //Cleanup and Init with 0 the szBuffer
     ZeroMemory(szBuffer,256);

     printf("\nPlease enter message to be sent to server: ");

     //Read the message from server
     fgets(szBuffer,255,stdin);

     int nBytesSent;
     int nBytesRecv;

     //Send the message to the server
     nBytesSent = send(Socket, szBuffer, strlen(szBuffer), 0);

     if (SOCKET_ERROR == nBytesSent)
     {
          closesocket(Socket);

          printf("\nError occurred while writing to socket.");
          goto error;
     }
     else
     {
          printf("\nsend() successful.");
     }

     //Cleanup and Init with 0 the szBuffer
     ZeroMemory(szBuffer,256);

     //Get the message from the server
     nBytesRecv = recv(Socket, szBuffer, 255, 0 );
  errno = GetLastError();

     if (SOCKET_ERROR == nBytesRecv)
     {
          closesocket(Socket);

          printf("\nError occurred while reading from socket.");
          goto error;
     }
     else
     {
          printf("\nrecv() successful.");
     }

     //Display the server message
     printf("\n%s", szBuffer);

     //Close the socket
     closesocket(Socket);

     //Cleanup Winsock
     WSACleanup();
     return 0; //success

error:
     // Cleanup Winsock
     WSACleanup();
     return 1; //error
}

////// end of my client code
0
ray
5/30/2008 2:33:41 PM
mozilla.dev.tech.xpcom 1345 articles. 0 followers. Post Follow

0 Replies
3090 Views

Similar Articles

[PageSpeed] 43

Reply:

Similar Artilces:

System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
Hello, I got this error today in an Application.  This app is coded in asp.net 2, using VB.  I have the Andri Code (http://makoto.madmedia.ca/2007/03/mysql-membership-and-role-provider-for.html) to connect asp.net with mysql. It has never caused errors in the past, I have the same configuration on another app that has been running for several months with no problem. This app is new (1 week) and today is the first day I see this error. Any ideas? Server Error in '/' Application.-------------------------------------------------------------------------------- An estab...

An established connection was aborted by the software in your host machine
hi, i write codings for sending email in asp.net ,there is no problem in the coding ,i dont know how to configure my smtp in IIS please help me to configure my smtp if i try to send email the below error was come.  Error: Server Error in '/WC_Finanzas' Application. An established connection was aborted by the software in your host machine Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.N...

An established connection was aborted by the software in your host machine
Hi All, I am trying to connect to the pop3 server to read mails from it. The server connects successfully but while logging user to the server from the code  I am getting the error Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machineThe server is using SSL. I am using asp.net 2.0 vb to connect to the server. ...

An established connection was aborted by the software in your host machine
Hello: Today I started my web application and it threw the following error: "An established connection was aborted by the software in your host machine" It highlighted the following line: "Dim myHttpResponse As Byte() = myHttpWebRequest.UploadData(ConfigurationSettings.AppSettings("url"), "POST", sendData)" Any suggestions on how I could fix this? At first I thought there might be a problem with the remote host it is trying to connect to, but the remote host works just fine... thanks. Need ASP.NET web hosting? Private Message ...

Socket Error # 10053 Software caused connection abort
After running flawlessly for 3 to 4 years, my application (Delphi 5, Indy 9.0.18) began to send "Socket Error # 10053 Software caused connection abort". This is an applet on 30 clients (WXP pro SP2/SP3) reading a table to format a message using TIdSMT and TIdMessage components. Every 4 mins, the table is browsed for new records and, if any, sends message(s) -about 40 messages a day on each client. Mail server is inside the building as are the recipients. Now, is failing 90% of the time throwing error # 10053. We goggled for solutions and tried some of them (disabling A...

Why do i recieve a error message "An establisted connection was aborted by the software in your host machine" when i try to recover the password?
Hi,  I'm trying to retrive use the password recovery to recover the password . But whenever i typed in the user password, there will be an error message saying that the "An establisted connection was aborted by the software in your host machine". How do you solve that? Thanks. Server Error in '/WSD Project - Cam-Mart' Application. An established connection was aborted by the software in your host machine Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error ...

socket error 10053
I took an application from my delphi 2009 to XE2 using datsnap, I am getting an error message random,'' socket error 10053 - sofware Caused connection abort'' and sometimes'' Gracefully Handle Connection'' someone help me, thanks > {quote:title=ERASMO GRASSI wrote:}{quote} > I took an application from my delphi 2009 to XE2 using datsnap, I am getting an error message random,'' socket error 10053 - sofware Caused connection abort'' and sometimes'' Gracefully Handle Connection'' someone help me, thanks HELP HELP HELP ...

An Unable to write data to the transport connectionestablished connection was aborted by the software in your host machine
 When i want to get access pop3 of gmail, i have an error below :System.IO.IOException: Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Socket...

CONNECTIVITY ERROR: DB-Library error: 'Unknown host machine name.'.
CONNECTIVITY ERROR: DB-Library error: 'Unknown host machine name.'. trying to start Sybase from sybinit. Logged in as user Sybase, set up with the script, etc. I *started* by putting 127.0.0.1 in as the address for the server. (that was the first address I tried (and it changed it to localhost). I've since changed it to many things. :) Both inside sybinit and manually editing $SYBASE/interfaces. my current $SYBASE/interfaces: [addison@localhost sybase]$ more interfaces ## SYBASE on 127.0.0.1 ## Services: ## query tcp (7100) ## ...

Socket Error #10053 on TIdTCPClient.Connect
I'm getting the Socket Error #10053 when the .Connect method is called, but only the first time the method is called while the app is running. Subsequent calls work successfully. So it seems that something maybe isn't initialized the first time the code is called. Client Code: {code} wTCPClient:=TIdTCPClient.Create(nil); wTCPClient.ConnectTimeout := 10000; wTCPClient.Host:=wServerName; wTCPClient.Port:=strtoint(wPort); if (wUseSSL) then begin wPasswordSetter := TPasswordSetter.Create; wSSLIOHandlerSo...

help. when using Profile GetPropertyValue, I get the following connection error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure
 Hi,I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property((string)(this.GetPropertyValue("Address1")));When I look at the stack, it is coming from my ProfileWrapper class which adds user address, city, etc.. from a class which inherits fromSystem.Web.Profile.ProfileBase. From the stack, it is calling the System.Web.Profile and crashed when it tries to open a connection atSystem.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObj...

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Hi All,  I have created a FTP client in ASP.net and it's working fine on my local system but when i deployed this code on Public IP(Remote server) it's not working.Code and Exceptions message are give below. public void Login() { if ( this.loggedin ) this.Close(); Debug.WriteLine("Opening connection to " + this.server, "FtpClient" ); IPAddress addr = null; IPEndPoint ep = null; try { this.clientSocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); addr = Dns.Resolve(this.serve...

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I am running a e-commerce website which will call a remote payment gateway when customer check out. with ASP.NET(2.0) The Bank Give Me WebService and say to me to use post method for sending my information. My Transaction State Is Ok But when i call a method of Bank webservice  it give me error   _______My Sample Code ___________ double TA;WebServices.ReferencePayment PaymentWebService = new WebServices.ReferencePayment();string MID = "00229018-45987";string t_strRefNum="*********";double t_lAmount;protected void Page_Load(object sender, EventArgs e) &n...

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
please can you help, when i do my request form i am getting an error. this happens when it is called over the web externally when i launch in visual stuido it works fine, i am local to the smtp server. it is an Exchange 2003 server. It has an address published, i can connect to port 25 with telnet to the dnsname.   I have many different snippets of code i have tried in a bid to get to the root, i think it cant authenticate. i have assigned 3 buttons to different subs for the mail send, noe of which work   A connection attempt failed because the connected party did not properly...

Web resources about - Socket error 10053(An established connection was aborted by the software in your host machine.) - mozilla.dev.tech.xpcom

Resources last updated: 1/22/2016 6:45:27 AM