Click here to Skip to main content
15,867,686 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: imaging code; looking for optimization Pin
Daniel Grunwald30-Sep-05 22:56
Daniel Grunwald30-Sep-05 22:56 
GeneralRe: imaging code; looking for optimization Pin
sarabjs3-Oct-05 6:30
sarabjs3-Oct-05 6:30 
Question.NET locking DLLs Pin
Gilad Kapelushnik26-Sep-05 23:48
Gilad Kapelushnik26-Sep-05 23:48 
Questiondrawing text on an image Pin
sarabjs26-Sep-05 5:30
sarabjs26-Sep-05 5:30 
AnswerRe: drawing text on an image Pin
Guido_d26-Sep-05 23:18
Guido_d26-Sep-05 23:18 
GeneralRe: drawing text on an image Pin
Guido_d26-Sep-05 23:34
Guido_d26-Sep-05 23:34 
GeneralRe: drawing text on an image Pin
sarabjs27-Sep-05 8:50
sarabjs27-Sep-05 8:50 
Question Strange behaviour with a System.Net.Sockets.Socket Pin
Guido_d26-Sep-05 3:53
Guido_d26-Sep-05 3:53 
Hi,

Strange behaviour with a System.Net.Sockets.Socket, reproducable on 95, 2000
and XP

If I reuse a socket object after initializing it I can reconnect without
problems.

But

If the application has been running for 23 minutes or longer, the socket
will forever
wait for BeginConnect() to finish. Confused | :confused:

If I use a Connect() (also after 23 minutes) instead of async connecting the call will block
forever. OMG | :OMG:

I am using the following (pseudo) code to test. If running this after 23
minutes, the connect fails
and it is impossible to reconnect without restarting the application.

Is this known behaviour? Is there a workaround? Am I making a mistake? Help would be greatly
appreciated. For the time being I dropped a winsock control on a form and use that as my async socket.

regards

Guido

this is the offending code:
<br />
class SocketConnector<br />
{<br />
 AsyncCallback m_callback = null;<br />
 System.Net.Sockets.Socket m_socket = null;<br />
 bool m_connected = false;<br />
 public bool Connected<br />
 {<br />
  get { return m_connected; }<br />
 }<br />
 public void Connect(string ipaddress, int port)<br />
 {<br />
  // set up callback<br />
  m_callback = new AsyncCallback( OnConnect );<br />
<br />
  // create socket<br />
  m_socket = new Socket (AddressFamily.InterNetwork,SocketType.Stream <br />
,ProtocolType.Tcp );<br />
  m_socket.Blocking = false;<br />
<br />
  // get the remote IP address<br />
  IPAddress ip = IPAddress.Parse (ipaddress);<br />
  int iPortNo = System.Convert.ToInt16 ( port);<br />
<br />
  //create the end point<br />
  IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);<br />
<br />
  // begin async connect<br />
  IAsyncResult ar = m_socket.BeginConnect( ipEnd, m_callback, m_socket );<br />
<br />
  // wait for connect<br />
  ar.AsyncWaitHandle.WaitOne(2000,false);<br />
<br />
  if (!ar.IsCompleted || m_callback!=null)<br />
  {<br />
   // BeginConnect did not finish, breakpoint here to test<br />
   m_connected = false;<br />
   // ..<br />
   return;<br />
  }<br />
  // beginconnect finished OK<br />
  m_connected = true;<br />
 }<br />
 void OnConnect(IAsyncResult result)<br />
 {<br />
  m_callback = null;<br />
 }<br />
} <br />
<br />

QuestionWhat API can be used to access MS Project? Pin
kurdi1926-Sep-05 3:14
kurdi1926-Sep-05 3:14 
QuestionXmlSerializer question Pin
Ivanets26-Sep-05 1:13
Ivanets26-Sep-05 1:13 
QuestionFind RichTextBox BackColor in VB.NET Pin
lupus canus25-Sep-05 23:56
lupus canus25-Sep-05 23:56 
AnswerRe: Find RichTextBox BackColor in VB.NET Pin
lupus canus26-Sep-05 7:12
lupus canus26-Sep-05 7:12 
QuestionIL and MSIL Pin
Rajesh_K_Sharma25-Sep-05 20:12
Rajesh_K_Sharma25-Sep-05 20:12 
AnswerRe: IL and MSIL Pin
Saqib Shakil25-Sep-05 21:28
Saqib Shakil25-Sep-05 21:28 
AnswerRe: IL and MSIL Pin
Dave Kreskowiak26-Sep-05 3:09
mveDave Kreskowiak26-Sep-05 3:09 
Questioninformation regarding stack trace Pin
ravibabu_kanaparthi25-Sep-05 19:20
ravibabu_kanaparthi25-Sep-05 19:20 
Question.Net Application not Runing on Test System Pin
Zishan Haider25-Sep-05 4:19
Zishan Haider25-Sep-05 4:19 
AnswerRe: .Net Application not Runing on Test System Pin
Steve Pullan25-Sep-05 14:17
Steve Pullan25-Sep-05 14:17 
GeneralRe: .Net Application not Runing on Test System Pin
Anonymous25-Sep-05 17:48
Anonymous25-Sep-05 17:48 
GeneralRe: .Net Application not Runing on Test System Pin
Steve Pullan25-Sep-05 20:28
Steve Pullan25-Sep-05 20:28 
GeneralRe: .Net Application not Runing on Test System Pin
Anonymous25-Sep-05 21:22
Anonymous25-Sep-05 21:22 
Questionchar * = new char[] take me an ERROR!!!! Pin
firefoxrabbit24-Sep-05 3:35
firefoxrabbit24-Sep-05 3:35 
QuestionWhich is efficient. using &quot;&quot; or string.Empty? Pin
manivannan.p24-Sep-05 3:00
manivannan.p24-Sep-05 3:00 
AnswerRe: Which is efficient. using &quot;&quot; or string.Empty? Pin
S. Senthil Kumar24-Sep-05 4:29
S. Senthil Kumar24-Sep-05 4:29 
AnswerRe: Which is efficient. using &quot;&quot; or string.Empty? Pin
Member 230255124-Sep-05 5:17
Member 230255124-Sep-05 5:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.