🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: finding if a port is idle?

#4304
From: Remy Lebeau (TeamB)
Date: Fri, 04 Mar 2005 06:55
46 lines
3027 bytes
"qyte" <gyte@vivodinet.gr> wrote in message
news:42279c95@newsgroups.borland.com...

> The Problem is that when i call SendBuf i want to
> know for sure if the data will be sent.

There is no way to determine that.  SendBuf() simply passes the data to the
socket, which buffers the data internally for later transmission.  There is
no way to know whether the socket will actually send the data.  All that is
returned to you is whether the socket accepted the data, but there is no way
to know what the socket actually does with the data.  Once the socket
accepts the data, it is out of your hands.

> I want to add an abort

The only way to abort a socket is to disconnect it.  Once the socket has
accepted the data, you cannot tell the socket later to ignore the data it
already accepted.

> even if i close the timer there is still some data on the winsock
> that will be sent in the future and of course when the receiver
> takes them and calls fwrite then an access violation accurrs.

Why would there be an AV?  Because you are writing to a closed file?  That
is your own responsibilty to keep track of in the first place.  Simply don't
write to files you have already closed.  Just discard the extra data.

> So i want to know when all the data will have gone

There is no way to know that.

> i know that i can call sendbuf like that:
>
> while(sendbuf(a,packet)<0);
>
> just to be certain that the data was sent. but there is no guarentee
> that the whole packet will be sent.

You need to examine the actual return value of SendBuf() to know how much
data was accepted by the socket.  If less then the original packet size then
you will have to re-send the remaining bytes in another call to SendBuf(),
repeating as needed until the packet has been passed to the socket in full.


Gambit
Technical Details
Message-ID: <42280656$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.bit.nl!newsfeed.bit.nl!news2.euro.net!demorgan.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4227924e$1@newsgroups.borland.com> <422799a5$1@newsgroups.borland.com> <42279c95@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3fedec5f2bb3f721
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: <4227924e$1@newsgroups.borland.com> <422799a5$1@newsgroups.borland.com> <42279c95@newsgroups.borland.com>
Subject: Re: finding if a port is idle?
Date: Thu, 3 Mar 2005 22:55:31 -0800
Lines: 48
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: 68.69.17.41
Message-ID: <42280656$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109919318 68.69.17.41 (3 Mar 2005 22:55:18 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.bit.nl!newsfeed.bit.nl!news2.euro.net!demorgan.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail