Delphi Socket Error 10049
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting windows socket error 10049 ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join asynchronous socket error 10049 the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes socket error errno 10049 a minute: Sign up getting asynchronous socket error 10049 even if i use try..except up vote 3 down vote favorite when ever i run my program(outside the debugger/ide) i get error asynchronous socket error 10049, am i not supposed to recieve socket error 10049 cannot assign requested address a message dialoge : ''error''? see my code below begin try ClientSocket1.open; except showmessage('error'); end; end; what am i doing wrong? delphi sockets exception-handling try-finally tclientsock share|improve this question asked Aug 1 '10 at 16:09 Omair Iqbal 1,0601639 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted What you should do is handle the Error event of the TClientSocket, because that is where you will be able to capture your socket errors. The ErrorCode parameter is
Delphi Socket Error 10061
the one that will have the WinSock Error code If you want to silence the Error, you can set ErrorCode to 0, which will prevent the exception from being thrown, and after that you can identify what the error is and handle it the way you want it procedure TForm1.ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); var error : Integer; begin error := ErrorCode; {prevent exception from being thrown} ErrorCode := 0; if error = 10049 then showmessage('asynchronous socket error'); . . . end; I hope this helps Gaetan Siry share|improve this answer answered Aug 1 '10 at 19:59 G-Man 3,600124575 thanks a heap.... –Omair Iqbal Aug 2 '10 at 6:13 add a comment| up vote -1 down vote The TClientsocket component (which is deprecated for a while already) uses the asynchronous communication model, so it is possible that the exception is not thrown in the Open method but in the message / event handling method which receives the incoming data. update: I can reproduce this with Delphi 6 and the given code, if I enter an invalid IP address like 1.2.3.4 To fix it I would move to a TCP/IP library like Indy or Ararat Synapse (both have a generic TCP client component). share|improve this answer edited Aug 1 '10 at 17:12 answered Aug 1 '10 at 17:00 mjn 23.5k15119276 the code works fine when its connected to server(which is in other program) but when serve
try to connect it gives me: Socket Error #10049 Can't assign requested address. can anyone help me out??? thanks a lot frank Stephan-Frank Henry ---------------------------------- FHe...@NoSpamAdulo.de Fran Delphi Developer Sun, 30 Mar 2003 03:00:00 GMT Re:Help: Socket Error#10049
Delphi Socket Error 10060
update: Quote> hi, > i built myself a little client/server programm, > when i insert delphi socket error 10054 the IP (localhost or 127.0.0.1) and try to connect > it gives me: > Socket Error #10049 > Can't assign requested address. > socket error 11004 delphi can anyone help me out??? > thanks a lot it has now changed to #10061 Connection refused! can anyone help out? frank Fran Delphi Developer Sun, 30 Mar 2003 03:00:00 GMT Re:Help: Socket Error#10049 Quote> > hi, http://stackoverflow.com/questions/3382707/getting-asynchronous-socket-error-10049-even-if-i-use-try-except > > i built myself a little client/server programm, > > when i insert the IP (localhost or 127.0.0.1) and try to connect > > it gives me: > > Socket Error #10049 > > Can't assign requested address. > > can anyone help me out??? > > thanks a lot > it has now changed to #10061 Connection refused! > can anyone help out? well i think i found my problem. sorta like in the http://www.delphigroups.info/2/4f/195430.html example i was using the idTCPServer.OnConnect to read data the client was supposed to write when connected. basically what i want to do is have the client and ther server excange info between each other. can anyone help me out? thanks again frank Fran Delphi Developer Mon, 31 Mar 2003 03:00:00 GMT Re:Help: Socket Error#10049 Quote> > > hi, > > > i built myself a little client/server programm, > > > when i insert the IP (localhost or 127.0.0.1) and try to connect > > > it gives me: > > > Socket Error #10049 > > > Can't assign requested address. > > > can anyone help me out??? > > > thanks a lot > > it has now changed to #10061 Connection refused! > > can anyone help out? > well i think i found my problem. > sorta like in the example i was using the idTCPServer.OnConnect to > read data the client was supposed to write when connected. > basically what i want to do is have the client and ther server excange info > between each other. > can anyone help me out? > thanks again argh... somebody beat me with a cottonswab!!! i figured out my problem. i had the TCPServer.Active := True in the ServerExecute event!
with a TServerSocket. The components are from Delphi 5 Pro ('Internet' tab). Here is my problem... I want to bullet proof the app, so http://www.delphigroups.info/2/23/183911.html that the user can tell the ClientSocket to try to connect to any old IP address and not have the app fall over stupidly. I have error handling in http://www.delphimaster.net/view/6-52318/all place so that I intercept all the usual errormessages, so that when the user types in an IP address that won't have my ServerSocket listening on the other end socket error it tells the user nicely that it 'Can't find the server there.'. This is now where my problem comes in... if the user tries to enter another incorrect IP address, instead of doing the same this ('Can't find the server there') I go and get an error that reads the following... Asynchronous Socket Error 10049 If I try for delphi socket error a third time with an incorrect IP, it seems to actually go look for the server again, and responds with the (desired) original 'Can't find server there'. Fourth time brings up this Asynchronous Socket Error 10049 again, and so the cyclie repeats. What gives, am I not closing the socket down or something? Here is my code to try and OPEN the connection... ClientSocket.Host := IPaddressEdit.Text; ClientSocket.port := 10000; ClientSocket.Active := true; Here is my code to try and CLOSE everything down ready to try again when I encounter an error in connecting... ClientSocket.Socket.Close; ClientSocket.Close; ClientSocket.Active:=false; Not entirely sure what I am doing here, Any help very gratefully received! -Peter Laurens Other Threads 1. Asynchronous socket error 10053 2. Asynchronous socket error 10053 3. I met Asynchronous Socket Error 10053! 4. Asynchronous Socket Error 10061 5. asynchronous socket error 10054 6. Asynchronous socket error in TServerSocket 7. Asynchronous socket error 10060 8. Asynchronous Socket error 10053 9. Asynchronous socket erro
[0] Подскажите пожайлуста, вот сделал одну форму занес на нее сервер сокет и кнопку, поле мемо еще, на событие он клик кнопки procedure TForm1.Button1Click(Sender: TObject); begin serverSocket1.active:=true; edit1.text:="Active"; end; на событие OnClientRead: procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket); begin if Socket.ReceiveText ="r" then edit1.text:="Conect complete"; end; на событие Дестрой формы: procedure TForm1.FormDestroy(Sender: TObject); begin ServerSocket1.active:=false; end; Порт выставил 3333 Потом сделал клиента на него кинул кнопку, на онклик кнопки клиента : procedure TForm1.Button1Click(Sender: TObject); begin clientsocket1.active:=true; clientsocket1.socket.sendtext("r"); clientsocket1.active:=false; end; в host написал: 127.0.0.1 и порт выставил:3333 ну и запускаю ето все дело а оно мне: Windows socket error: (10049), on API "connect" чтож делать то? TButton (2003-10-16 04:45) [1] на БатонКлик client.Socket.Open; на ClientSocketConnect clientSocket.Socket.SendText("r"); clientSocket.Close; Digitman (2003-10-16 08:42) [2] Specifies an alias for the IP address of the server system. property Host: string; Description Host is a string containing the domain name and service of a particular system, such as http://www.wSite.Com For client sockets, set Host to the system with which the client socket should form a connection. When the socket opens a connection, it looks up the IP address for the server socket using the value of Host. Some servers change the system or IP addre