🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1347

Re: socket issue

#1347
From: Remy Lebeau (TeamB)
Date: Fri, 09 Feb 2007 18:35
57 lines
2843 bytes
"mat" <mat@hotmail.com> wrote in message
news:45cbd7c8$1@newsgroups.borland.com...

> hello,im using a socketconnection component

Which component specifically?

> the code is in a separate thread and i have some
application->processmessages
> in order to get some visual feedback (e.g. a messagebox before
> it starts connected and a messagebox if it connects).

You should not be calling Application->ProcessMessages() in a worker
thread.  Only call it in the main thread.  Besides, you don't need it
anyway.  You can call the Win32 API MessageBox() directly in a worker
thread without processing any messages at all, as it has its own
message processing internally.

> if its not up (e.g. if im not running the scktsrv.exe)it throws an
exception.

As it should be.

> when i try to connect to an not existing pc (wrong ip) the system
> freezes and waits for a rather big timeout.

Again, as it should be.  If the IP cannot be reached immediately, it
can take a long time for the OS to figure out whether the IP is
actually valid or not.

> if i try to connect to a firewalled pc (which blocks such incomming)
> it freezes again and waits for a rather big timeout again.

See above.  If the firewall is blocking communications, then it is
likely also blocking the packets that the OS needs to determine
whether the machine is present or not at the IP.

> is this something i can fix?

The only thing you can do is implement your own timeout on the
connection manually.  You did not say whether the socket was
asynchronous or synchronous.  It makes a big difference in how to
implement such a timeout.

> the waiting timeout is very big

Such is the nature of sockets, especially on Windows.  Microsoft likes
to use large timeouts that cannot be changed.

> the program freezes (although its in its own thread).

The program cannot be freezing unless you are making your main thread
wait on the socket thread while it is waiting on the socket.


Gambit
Technical Details
Message-ID: <45ccbf29$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45cbd7c8$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,54a50302c070b08c
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <45cbd7c8$1@newsgroups.borland.com>
Subject: Re: socket issue
Date: Fri, 9 Feb 2007 10:35:46 -0800
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <45ccbf29$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1171046185 75.83.34.171 (9 Feb 2007 10:36:25 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail