With TCustomWinSock How to retry Open()

I am using the depreciated component TCustomWinSocket in CB XE4 with the VCL Windows 32 platform.  When I call Socket->Open() I sometimes get the Error Event, eeConnect (A connection request that was already accepted could not be completed). At the current time I have to restart the application to open the socket. Can someone show how I would reset the socket and try to open the socket again without restarting the app. Below is my code for opening the socket and the error event.  Thanks.   


  
  if(MySocket_M->Socket->Connected == false)
  {
	MySocket_M->Port = MyGetFeedPort("DataPort");
	MySocket_M->Open();
  }



void __fastcall TMainForm::MySocket_MError(TObject *Sender, TCustomWinSocket *Socket,
		  TErrorEvent ErrorEvent, int &ErrorCode)
{

  UnicodeString eemsg, msg;

  if(ErrorEvent==eeGeneral){
	eemsg ="Socket Error. Unknown generic Socket error.(Msg 29359)";
  }else if(ErrorEvent==eeSend){
	eemsg ="Socket Error. An error occurred when trying to write to the socket connection.(Msg 29360)";
  }else if(ErrorEvent==eeReceive){
	eemsg ="Socket Error. An error occurred when trying to read from the socket connection.(Msg 29361)";
  }else if(ErrorEvent==eeConnect){
	eemsg ="Socket Error. A connection request that was already accepted could not be completed. (Msg 10061)";
  }else if(ErrorEvent==eeDisconnect){
	eemsg ="Socket Error. An error occurred when trying to close a connection.(Msg 29363)";
  }else if(ErrorEvent==eeAccept){
	eemsg ="Socket Error. A problem occurred when trying to accept a client connection request.(Msg 29364)";
  }else{
	eemsg ="Socket Error. Server is not available to Socket Port.(Msg 29365)";
  }

  msg = eemsg+" Error Number("+IntToStr(ErrorCode)+")";
  ShowMessage( msg );
  ErrorCode=0;
 
}
//---------------------------------------------------------------------------
0
Patrick
1/23/2015 6:35:05 PM
embarcadero.cppbuilder.socket 566 articles. 0 followers. Follow

1 Replies
1993 Views

Similar Articles

[PageSpeed] 24
Get it on Google Play
Get it on Apple App Store

Patrick wrote:

> I am using the depreciated component TCustomWinSocket in CB XE4 with
> the VCL Windows 32 platform.

More accurately, you are using the TClientSocket component.

> When I call Socket->Open() I sometimes get the Error Event, eeConnect

Are you using TClientSocket in blocking or non-blocking mode?

> At the current time I have to restart the application to open the socket.

No, you don't.  Simply Close() the socket, and then re-Open() it after a 
small delay.

-- 
Remy Lebeau (TeamB)
0
Remy
1/26/2015 8:51:41 PM
Reply:

Similar Artilces:

open socket
why i open socket with Socket(); to host "localhost", protocol "tcp" & port "110" {for POP3}???? i can it make only with IO::Socket::INET->new(PeerAddr=>$host, PeerPort=>$port, Proto=>$proto); : :.. Roman Fordinal :.: fordinal@slovanet.sk I don't understand your question. Do you don't want use IO::Socket but the low level socket function???? Walter >why i open socket with Socket(); to host "localhost", protocol "tcp" & >port "110" {for POP3}???? >...

Failed to open; retrying..
Hi Wasn't sure which one to use; not sure from the TID 7001525 IPPSRVR dated 26/03/2008 or 19/07/2007 ? Please advise Thanks Currently using 06/09/2008 prntnw65sp7b and previously we had 26/03/2008? Thanks -- PSODHI ------------------------------------------------------------------------ IPPSRVR.NLM v4.00.12 dated 19/7/2007 worked around the issue for us. Matt -- leekie ------------------------------------------------------------------------ leekie's Profile: http://forums.novell.com/member.php?userid=6561 View this thread: http://for...

Number of open sockets
------=_NextPart_000_000F_01C26EB1.5C9EC150 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Is there a way to keep track of the number of open sockets your program = might have that are in a TIME_WAIT (I think it is) state? ------=_NextPart_000_000F_01C26EB1.5C9EC150-- Not answering the question, more like adding to it. :) There was recently a fair bit of discussion on Perl profilers. I wonder if a Profiler would be applicable to socket info? >===== Original Message From "Jessee Parker" <jparker@pr...

Open Socket problem
Hi We have this problem: messages in errorlog: "Error: 1605, Severity: 18, State: 1 Failed to open virtual socket for new connections" I know , that the "maximum number of virtual sockets = number of user connections + number of remote sites + 3" In our case number of user connections=100, number of remote sites = 10 then maximum number of virtual sockets = 113 Ok, using dbcc resource and dbcc traceon(3604) I've checked current configuration for sockets: cnsocket=127 I've also checked @@max_connections and etc: @@max_connections = 611...

Open socket connection...
I need to send some parameters to a .dll file and request the parameters that it sends back respectivly.  I have to keep the socket open for 2-4 seconds then close it.  Here is my code below.  Not sure why it isn't working.   'Send operations will time-out if confirmation is   ' not received within 1000 milliseconds.   Dim sktConnect As Socket   sktConnect.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000)    Response.Redirect("https://testefsnet.concordebiz.com/EFSnet.dll?Me...

failed to open, retrying
Since a server restart (nw65sp7 + latest iPrint patches server and client side), it appears that when an iPrint printer has jobs queued up on it, when you double click the printer icon in Windows XP, 'printers and faxes' you see a 'failed to open, retrying' message. Prior to the double click you can see the number of jobs queued, and that the printer is ready, but the double click fails to list the queued jobs with the 'failed to open, retrying' message being displayed in the title bar of the job window. This is happening on 4.38 and 5.12 iPrint clients, on...

Retrying a Objconn.Open()
I've developed a VB.NET application using an Access Database (customer request).  Now that we've launched it and more people accessing it, we're getting quite a few "System.Data.OleDb.OleDbException: Unspecified error" errors during ObjConn.Open() commands.Is there a way to ignore this and retry opening the database until it is actually available. All our calls to the database execute the query and then close it, so it shouldn't be open for long.Thanks!  Access has a limited number of connections.  You may be exceed the connection.  I...

Unable to open socket
The database is SQL Server 10.0.1 running on SCO Open Server version 3.0. Our application runs on another machine also on SCO Open Server version 3.0. The application retrieves data from the SQL Server using Open Client of ver 10.0.1. We are replacing SQL Server 10.0.1 with ASE 12.0 on Sun Solaris as the Database server. However, the application will remain the same i.e. running on SCO Open Sever version 3.O. Please let us know how to connect to ASE 12.0 on Solaris the Open Client 10.0.1 on SCO Open Server version 3.0 ??? Isql returns 'Unable to open socket' e...

Tracking open sockets
How would one get a list of open sockets on a Windows 95/98/NT system and track them down to the process that owns them. I'm looking for netstat like functionality to get a list of sockets and then a way to eventually track them down to the executable that opened them. thanks, Gary Flynn Security Engineer (and part-time programmer :) There is a netstat command on the command prompt (dos emulator). It gives unix equivalent stuff. Regis. Thanks. How do I duplicate its functionality programatically ? I want to be able to scan active ports and track down the executabl...

Open Ports what opened them
How I find out what program has opened a port on my computer. port 2105 -- There is an old Vulcan proverb. Only Nixon could go to China. Brady Wang wrote: > How I find out what program has opened a port on my computer. You can use AtGuard (no longer available), Norton Internet Security / Norton Personal Firewall (non free) <http://www.symantec.com>, TCPView Pro (non free) <http://www.winternals.com/>, Fport (free but NT/2000 only) <http://www.foundstone.com/> and a few other tools. Sebastian ...

Failed to open virtual socket
Hi ! I've got SAE 11.9.2 (Adaptive Server Enterprise/11.9.2/1031/P/NT (IX86)/OS 3.51,4.0) running on W2000 and last week I started to receive such messages in errorlog: "Error: 1605, Severity: 18, State: 1 Failed to open virtual socket for new connections" I know , that the "maximum number of virtual sockets = number of user connections + number of remote sites + 3" In my case number of user connections=100, number of remote sites = 10 then maximum number of virtual sockets = 113 Ok, using dbcc resource and dbcc traceon(3604) I've ...

Open with newsgroups open ??
Is there any way with Mozilla or Thunderbird to have the newsgroups open when the application is started? It's annoying to have to scroll down to the news server and click the + beside it every time. Larry Hazel wrote: > Is there any way with Mozilla or Thunderbird to have the newsgroups open > when the application is started? It's annoying to have to scroll down > to the news server and click the + beside it every time. Push * on your keyboard. or change your view settings to "sort by --> unthreaded" or date or something. Regards, Nathani...

open question... very open.
heh... to make it simple: what are the significant differences between FreeBSD and Linux? please forgive my lack of articulation or specification with this question, but it's 2 a.m. (not really _that_ late in nerd-times), and i figure the broader i am the more sources i'll recieve (hopefully). anyway, thanks for the help, even some URLs would be nice, -k. ALL Linux are based around the same code. I believe that FreeBSD is based around different code (although it probably looks the same). FreeBSD behaves like linux. Then again I may be wrong, "Connolly" <Ke...

Web resources about - With TCustomWinSock How to retry Open() - embarcadero.cppbuilder.socket

Resources last updated: 12/6/2015 12:14:04 PM