[twsocket] TWSocket.Close() blocks on certain machines after sending UDP

2011-07-12 Thread Merijn Bosma

Hi all,

I've been using ICS for a long time, in different environments and on 
different machines without problems.
Now I've stumbled upon a problem of which at the moment I don't know how 
to find a solution for. It's regarding a snippet which sens data using UDP.

The relevant code boils down to:


  with TWSocket.Create(nil) do
  begin
   Proto := 'udp';
   Port := some port;
   Addr := some ip;
   Connect();
   SendStr('some data');
   Close();
   Free();
  end;

Very simple, and works great.

Now on two machines we have an issue while using this code. The call to 
Close() will block for 4 to 6 seconds if:

- I'm sending to an IP address within my own subnet
- There is no actual PC at that IP (doesn't have to be running a UDP 
server, just a PC with that ip address).


I've tried with different NIC's, and now I have a NIC on USB, which 
gives this problem on the 2 machines mentioned before (Win 7 Pro SP1), 
but do not have the same issue on another machine (Win 7 Pro SP1).


Obviously there is something with these two machines, but I'd like to 
know what is causing this to give me some control over it. These are 
brand new machines, firewall is disabled and all pre installed software 
is removed. I also have a support call at the manufacturer, but since 
there is not much promising result from them I'm hoping anyone here can 
give me a pointer in the right direction.


Thanks and regards!

Merijn

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Hang in TIcsWndControl.ProcessMessages

2011-07-12 Thread Eugene Kotlyarov
 Does anyone have ideas why TIcsWndControl.ProcessMessages could
 hang sometimes when socket is used in separate thread?

Have you followed the rules: create TWSocket within the thread's execute
method OR call ThreadAttach ?

 Yes socket is created within threads execute method, and it works most of 
 the time.
 I call it after calling shutdown like this, could it be related?

  FSocket.Shutdown(SD_BOTH);

What do you mean by I call it after... ?

Actually ProcessMessages probably doesn't hang. ProcessMessages it the place 
from where all events are called. It is likely an event handler which is 
blocking. You should try to find out where.

I call it like this, the only event that is called is SslShutDownComplete which 
sets FSSLShutdownComplete property, I don't have any other event processing here

  FSocket.Shutdown(SD_BOTH);

  EndTime := GetTickCount + FTimeout;
  while {$IFDEF USE_SSL} not FSSLShutdownComplete {$ELSE} False {$ENDIF} do
  begin
if GetTickCount  EndTime then
  break;
Sleep(10);
FSocket.ProcessMessages;
  end;


I am now trying to use only main thread with socket, but there is another 
problem when I use it directly from main thread it works fine, but when I call 
it using Synchronize from another thread after first portion of data is sent 
socket closes with 10053 error. Any ideas what could be the problem? It is an 
SSL connection.
And how to recover from 10053 error? When I call Socket.Connect again it still 
remains closed.
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Close() blocks on certain machines aftersending UDP

2011-07-12 Thread Arno Garrels
Merijn Bosma wrote:
 Hi all,
 
 I've been using ICS for a long time, in different environments and on
 different machines without problems.
 Now I've stumbled upon a problem of which at the moment I don't know
 how to find a solution for. It's regarding a snippet which sens data
 using UDP. The relevant code boils down to:
 
 
   with TWSocket.Create(nil) do
   begin
Proto := 'udp';
Port := some port;
Addr := some ip;
Connect();
SendStr('some data');
Close();
Free();
   end;
 
 Very simple, and works great.
 
 Now on two machines we have an issue while using this code. The call
 to Close() will block for 4 to 6 seconds if:
 - I'm sending to an IP address within my own subnet
 - There is no actual PC at that IP (doesn't have to be running a UDP
 server, just a PC with that ip address).

That sounds very similar to an issue Francois reported several months
back and which turned out to be a winsock bug IMO.
In Vista+ winsock repeated the ARP request within a few seconds 2 times
to get the MAC address that accepts packets for the destination if the 
request failed because the destination did not exist.
In Win XP there's only one ARP request sent.

The call to WSocket_Synchronized_closesocket(FHSocket) which calls
the native winsock API function doesn't return while winsock is still
trying to get the MAC address of a non-existing host.

-- 
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Close() blocks on certain machines aftersending UDP

2011-07-12 Thread Francois PIETTE
I suggest you look at security software which may be installed on those 
PC. Some of those software (anti-malware, firewall, proxy,...) are 
malfunctionning in their interception of socket communication. So first do a 
test with every security software disabled.


It may also be a virus or trojan which intercept socket communication for 
malware. So here turn all security on, do an complete malware check (update 
your software !). Also try to detect root kits which may be there.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

- Original Message - 
From: Merijn Bosma bo...@xs4all.nl

To: twsocket@elists.org
Sent: Tuesday, July 12, 2011 1:49 PM
Subject: [twsocket] TWSocket.Close() blocks on certain machines aftersending 
UDP




Hi all,

I've been using ICS for a long time, in different environments and on 
different machines without problems.
Now I've stumbled upon a problem of which at the moment I don't know how 
to find a solution for. It's regarding a snippet which sens data using 
UDP.

The relevant code boils down to:


  with TWSocket.Create(nil) do
  begin
   Proto := 'udp';
   Port := some port;
   Addr := some ip;
   Connect();
   SendStr('some data');
   Close();
   Free();
  end;

Very simple, and works great.

Now on two machines we have an issue while using this code. The call to 
Close() will block for 4 to 6 seconds if:

- I'm sending to an IP address within my own subnet
- There is no actual PC at that IP (doesn't have to be running a UDP 
server, just a PC with that ip address).


I've tried with different NIC's, and now I have a NIC on USB, which gives 
this problem on the 2 machines mentioned before (Win 7 Pro SP1), but do 
not have the same issue on another machine (Win 7 Pro SP1).


Obviously there is something with these two machines, but I'd like to know 
what is causing this to give me some control over it. These are brand new 
machines, firewall is disabled and all pre installed software is removed. 
I also have a support call at the manufacturer, but since there is not 
much promising result from them I'm hoping anyone here can give me a 
pointer in the right direction.


Thanks and regards!

Merijn

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Hang in TIcsWndControl.ProcessMessages

2011-07-12 Thread Francois PIETTE

Does anyone have ideas why TIcsWndControl.ProcessMessages could
hang sometimes when socket is used in separate thread?


Actually ProcessMessages probably doesn't hang. ProcessMessages it the 
place

from where all events are called. It is likely an event handler which is
blocking. You should try to find out where.


I call it like this, the only event that is called is SslShutDownComplete 
which
sets FSSLShutdownComplete property, I don't have any other event 
processing here


 FSocket.Shutdown(SD_BOTH);

 EndTime := GetTickCount + FTimeout;
 while {$IFDEF USE_SSL} not FSSLShutdownComplete {$ELSE} False {$ENDIF} do
 begin
   if GetTickCount  EndTime then
 break;
   Sleep(10);
   FSocket.ProcessMessages;
 end;


I don't know from where this code is called, but it CANNOT be called from an 
event handler originating from TWSocket.


ProcessMessage is actually calling the window procedure for all windows 
created in the thread context and in turn trigger events at the component 
level. If any event hanlder is blocking, the ProcessMessages looks blocking. 
Calling Synchronize will actually block the thread until the main thread has 
time to process a message.



--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Close() blocks on certain machines aftersending UDP

2011-07-12 Thread Merijn Bosma

New message while I was typing the reply to the previous one :)

Fraincois, I've been able to reproduce this on a fresh installed machine 
(no internet connection). Windows firewall is disabled, no extra 
software installed. I think that will rule out a external software issue?

Besides, we see exactly the same behavior on two independent machines.

Thanks for the info.

Merijn

On 7/12/2011 19:31, Francois PIETTE wrote:
I suggest you look at security software which may be installed on 
those PC. Some of those software (anti-malware, firewall, proxy,...) 
are malfunctionning in their interception of socket communication. So 
first do a test with every security software disabled.


It may also be a virus or trojan which intercept socket communication 
for malware. So here turn all security on, do an complete malware 
check (update your software !). Also try to detect root kits which may 
be there.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

- Original Message - From: Merijn Bosma bo...@xs4all.nl
To: twsocket@elists.org
Sent: Tuesday, July 12, 2011 1:49 PM
Subject: [twsocket] TWSocket.Close() blocks on certain machines 
aftersending UDP




Hi all,

I've been using ICS for a long time, in different environments and on 
different machines without problems.
Now I've stumbled upon a problem of which at the moment I don't know 
how to find a solution for. It's regarding a snippet which sens data 
using UDP.

The relevant code boils down to:


  with TWSocket.Create(nil) do
  begin
   Proto := 'udp';
   Port := some port;
   Addr := some ip;
   Connect();
   SendStr('some data');
   Close();
   Free();
  end;

Very simple, and works great.

Now on two machines we have an issue while using this code. The call 
to Close() will block for 4 to 6 seconds if:

- I'm sending to an IP address within my own subnet
- There is no actual PC at that IP (doesn't have to be running a UDP 
server, just a PC with that ip address).


I've tried with different NIC's, and now I have a NIC on USB, which 
gives this problem on the 2 machines mentioned before (Win 7 Pro 
SP1), but do not have the same issue on another machine (Win 7 Pro SP1).


Obviously there is something with these two machines, but I'd like to 
know what is causing this to give me some control over it. These are 
brand new machines, firewall is disabled and all pre installed 
software is removed. I also have a support call at the manufacturer, 
but since there is not much promising result from them I'm hoping 
anyone here can give me a pointer in the right direction.


Thanks and regards!

Merijn

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Close() blocks on certainmachines aftersending UDP

2011-07-12 Thread Francois PIETTE

AFAIR the workaround was to do your own ARP request first in order
to check whether the destination exists or not, utilizing the IP Helper 
API.



Yes, that what I did.



How can I confirm that this is what's happening with me?


In my case, the blocking was occuring in the main thread. TO see it it was 
then easy: using the mouse, I moved continuously the form in small circles. 
When blocked, the application don't paint the form and the window was stuck. 
Then using WireShark I was able to see that the blocking was when ARP 
requests were sent to non existant address.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be