473,545 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is socketbuffer empty?

Hello Fellow Developer,

This looks like a long mail, but at the end of this post is my socket
wrapper attached.
I want to make a timeout procedure that starts counting down after the
socketbuffer is empty.
This connection is being used to transmit data following a RFC so I cann't
create a control protocol that tells me the data was received.
(And even if I could, I want the timeout procedure to start after I send all
data, because that makes for me the most sense. (say I am sending 128mb the
socket will take longer sending then the timeout interval))
Any questions/remarks, NOT related to my question, pls ask directly via
email, dont post on the news server because It toke me alot of effort to
create this post.

Sample case:
if u send 1 byte from a client in Canada to a server in Australia with a 28k
modem thats being shared by an office of 30 people connected to the slowest
profider. (etc.)
What I want to say is that 1 byte may take a couple of minutes, and I use 1
byte as an
example because I don't want to make a question more complicated.

TCP/IP is a async protocol, but due to the Berkley Connection engine it
keeps track of what was send and received and what was not, so when there is
a packet loss it will send again.
So a socket keeps the data sequential, and if we are optimistic, the only
thing that can go wrong is a socket error.

There are three stadiums(simpli fied):
(A) My object sends to the Winsock, (buffer is being fed, no data on the
network, no data on the remote point)
(B) Winsock processes his buffer and sends on the network and waits for a
confirment that the package is succesfull transmitted(buf fer is 'empty',
data on the network, no data on the remote point)
(C) All data is correctly processed and transported (buffer is truely empty,
no data on the network,data on the remote point)

Relative to the Sample case:
I achieve (A) ofcourse, I would really want to know (C), but I would be
satisfied with (B). I know (B) can be achieved, I hope (C) is too.

VB.NET FrameWork 2003(all patched and updated):
I use the System.Net.Sock ets to send/receive data (no
tcpclient/tcplistener), I made a receivethread in my wrapper, the
receivethread loops/sleeps while waiting for data and then fires a
datareceived event.
Within the waitingloop there is a timeout function but this doesn't work
properly (It will never timeout).
When I send by System.Net.Sock ets.Socket.Send (buffer()) (<--this can be
10Mb) then it imitially returns to my thread, so the (internal) Send method
buffers it.
The System.Net.Sock ets.Socket is a wrapper around the Win32 Socket 2 API's,
it makes internal calls to those api's, so I started reading if they forgot
implementing some functions, but they are all implemented.

I tried:
- The beginSend/EndSend (Async way with callback when command is finished)
This calls within the async object the Socket.Send method, so its no
help, I can better do Socket.Send myself.
- The Socket.Blocking Property, it only blocks the Receive method,
Socket.Send goes directly in the buffer and then it returns immitially.
- Socket.Poll Method, returns the accessrights of the socket, "may I use
this socket to write?"
-
getSocketOption (Socket/TCP/IP,SendBuffer/ReceiveBuffer/SendLowWater/ReceiveL
owWater/SendTimeout/ReceiveTimeout) Method
Throws an Exception

MyWrapper.vb:
Imports System
Imports System.Net
Imports System.Net.Sock ets
Imports System.IO
Imports System.Collecti ons
Imports System.Threadin g
Imports System.Diagnost ics

Public Class SmartConnection
Public Event ConnectionOpene d(ByVal pMe As SmartConnection )
Public Event DataReceived(By Val pMe As SmartConnection , ByVal Data As
Message)
Public Event CouldntConnect( ByVal pMe As SmartConnection )
Public Event ConnectionClose d(ByVal pMe As SmartConnection )
Public Event [Error](ByVal pMe As SmartConnection , ByVal pErr As
Exception)
Public Event TimeOut(ByVal pme As SmartConnection )

Private _Socket As Socket
Private _ReadThread As Thread
Private _StopThread As Thread 'Lookup threadingpool
Private _Closing As Boolean = False
Private _InError As Boolean = False
Private _lport As Long
Private lasttimeout As Long
Private pHost As String
Private pPort As Long
Private pRead As Boolean
Private pTimeout As Long
Private _Iswriting As Boolean = False

Protected Overrides Sub Finalize()
_ReadThread = Nothing
_StopThread = Nothing
_Socket = Nothing
MyBase.Finalize ()
End Sub

#Region " Properties"
Public ReadOnly Property IsClosing() As Boolean
Get
IsClosing = (_Closing Or _Socket Is Nothing)
End Get
End Property

Public ReadOnly Property Connected() As Boolean
Get
Try
Connected = ((Not IsClosing) AndAlso _Socket.Connect ed =
True)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Protected ReadOnly Property Receiving() As Boolean
Get
Try
If Not Connected Then Throw New Exception("Sock et is not
connected")
Receiving = ((Not _ReadThread Is Nothing) AndAlso
_ReadThread.IsA live)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Public ReadOnly Property IPlocal() As String
Get
Try
If Connected Then IPlocal = EP2IPS(_Socket. LocalEndPoint)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Public ReadOnly Property IPremote() As String
Get
Try
If Connected Then IPremote = EP2IPS(_Socket. RemoteEndPoint)
Catch e As Exception
OnError(e)
End Try
End Get
End Property
#End Region
#Region " Connect"
Public Overridable Sub ConnectTo(ByRef hostName As String, ByRef port As
Long, Optional ByVal timeout As Long = 0)
Try
StartConnect(ho stName, port, timeout, True)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub ConnectToWithou tReading(ByRef hostName As String, ByRef
port As Long, Optional ByVal timeout As Long = 0)
Try
StartConnect(ho stName, port, timeout, False)
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub StartConnect(By Ref hostName As String, ByRef port As Long,
ByRef timeout As Long, ByRef read As Boolean)
Try
If Not _ReadThread Is Nothing Then Throw New Exception("Alre ady
trying to connect")
_ReadThread = New Thread(AddressO f ConnectThread)
pHost = hostName : pPort = port : pRead = read : pTimeout =
timeout
_ReadThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub ConnectThread()
Try
If pHost = "" Then Throw New ArgumentNullExc eption("hostnam e")
If pPort < IPEndPoint.MinP ort Or pPort > IPEndPoint.MaxP ort Then
Throw New ArgumentOutOfRa ngeException("p ort", "ArgRange_Port" )
_Socket = New Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p)
Try
_Socket.Blockin g = True
_Socket.Connect (New
IPEndPoint(Dns. Resolve(pHost). AddressList(0), pPort))
_lport = CType(_Socket.L ocalEndPoint, IPEndPoint).Por t
If Not pRead Then
SetReadName("SC .Read[PreConnect]")
_ReadThread = Nothing
Else
SetReadName("SC .EarlyRead[" & _lport & "]")
End If
OnConnectionOpe ned()
If pRead Then Receive()
Catch e As SocketException 'e.ErrorCode = 10061
SetReadName("SC .Read[NoConnect]")
_ReadThread = Nothing
OnCouldntConnec t()
Close()
End Try
Catch e As Exception
SetReadName("SC .Read[Error]")
_ReadThread = Nothing
OnError(e)
End Try
End Sub
#End Region
#Region " Receive"
Protected Sub StartReceive()
Try
If Receiving Then Throw New Exception("Rece iving was already
started")
_ReadThread = New Thread(AddressO f Receive)
SetReadName("SC .LateRead[" & _lport & "]")
_ReadThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub Receive()
Dim i As Long
Dim b() As Byte
'Dim ds As String, dt As String
Try
Do While Connected
If pTimeout > 0 Then lasttimeout = CurrTick() + pTimeout
Do While _Socket.Availab le = 0
'dt = ds
'ds = "@" & _lport & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket,
SocketOptionNam e.SendBuffer) & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket,
SocketOptionNam e.SendLowWater) & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket,
SocketOptionNam e.SendTimeout)
'Debug.WriteLin eIf(dt <> ds, ds)
_ReadThread.Sle ep(ReceiveWait)
If IsClosing Then Exit Sub
If _Socket.Poll(0, SelectMode.Sele ctError) Then

'System.Runtime .InteropService s.Marshal.GetLa stWin32Error())
'_Socket.GetSoc ketOption(Socke tOptionLevel.IP ,
SocketOptionNam e.Error)
OnError(New Exception("Sock et Error"))
End If
If pTimeout > 0 Then
'If _Socket.Poll(0, SelectMode.Sele ctWrite) Then
'lasttimeout = CurrTick() + pTimeout
'Else
If lasttimeout <= CurrTick() Then
OnTimeOut()
Close()
Exit Sub
End If
'Endif
End If
Loop
ReDim b(_Socket.Avail able - 1)
'SyncLock _Socket
i = _Socket.Receive (b, SocketFlags.Non e)
'End SyncLock
If i < b.Length Then ReDim b(i - 1)
OnMessageReceiv ed(New Message(b))
b = Nothing
Loop
Catch e As ThreadAbortExce ption
Exit Sub
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region
#Region " Send"
Public Overridable Overloads Sub Send(ByRef data As String)
Try
Send(getbytes(d ata))
Catch e As Exception
OnError(e)
End Try
End Sub

Public Overridable Overloads Sub Send(ByRef data() As Byte)
Try
If Not Connected Then Throw New Exception("Sock et isn't
connected")
_Iswriting = True
'SyncLock _Socket
_Socket.Send(da ta)
'End SyncLock
_Iswriting = False
Catch e As Exception
_Iswriting = False
OnError(e)
End Try
End Sub
#End Region
#Region " Close"
Public Overridable Sub Close() 'OR QUEE IT?
Try
If IsClosing Then Throw New Exception("Alre ady is closing")
_Closing = True
_StopThread = New Thread(AddressO f DoClose)
_StopThread.Nam e = "SC.Stop[" & _lport & "]"
_StopThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub DoClose()
Try
_StopThread.Sle ep(CloseWait)
Try
If Not _ReadThread Is Nothing Then
SetReadName("SC .Read[Close]")
If _ReadThread.IsA live Then _ReadThread.Abo rt()
End If
Catch e As Exception
End Try
Try
If Not _Socket Is Nothing AndAlso _Socket.Connect ed Then
_Socket.Close()
Catch e As Exception
End Try
_ReadThread = Nothing
_Socket = Nothing
_Closing = False
_StopThread = Nothing
OnConnectionClo sed()
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region
#Region " OnEvent"
Protected Overridable Sub OnError(ByRef pErr As Exception) 'If 2 errors
in diff threads?
Try
If Not _InError Then
_InError = True
Close()
_InError = False
End If
RaiseEvent Error(Me, pErr)
Catch e As Exception
Throw e
End Try
End Sub

Protected Sub OnTimeOut()
Try
RaiseEvent TimeOut(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnCouldntConnec t()
Try
RaiseEvent CouldntConnect( Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnConnectionClo sed()
Try
RaiseEvent ConnectionClose d(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnConnectionOpe ned()
Try
RaiseEvent ConnectionOpene d(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnMessageReceiv ed(ByRef data As Message)
Try
RaiseEvent DataReceived(Me , data)
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region

Private Sub SetReadName(ByR ef pName As String)
If Not _ReadThread Is Nothing AndAlso _ReadThread.Nam e Is Nothing
Then _ReadThread.Nam e = pName
End Sub

End Class
Jul 21 '05 #1
2 1839
Actually Socket.Poll doesn't return the access rights, it tells you the
state of the socket. For example if you do a Send and then do a:

Socket.Poll(Sel ectMode.SelectR ead)

It will return false until the server sends a response.

I think that's the closest you can get to what you want.

-Ron

"Robert A. van Ginkel" <ro****@stylega te.com> wrote in message
news:uS******** ******@TK2MSFTN GP10.phx.gbl...
Hello Fellow Developer,

This looks like a long mail, but at the end of this post is my socket
wrapper attached.
I want to make a timeout procedure that starts counting down after the
socketbuffer is empty.
This connection is being used to transmit data following a RFC so I cann't
create a control protocol that tells me the data was received.
(And even if I could, I want the timeout procedure to start after I send all data, because that makes for me the most sense. (say I am sending 128mb the socket will take longer sending then the timeout interval))
Any questions/remarks, NOT related to my question, pls ask directly via
email, dont post on the news server because It toke me alot of effort to
create this post.

Sample case:
if u send 1 byte from a client in Canada to a server in Australia with a 28k modem thats being shared by an office of 30 people connected to the slowest profider. (etc.)
What I want to say is that 1 byte may take a couple of minutes, and I use 1 byte as an
example because I don't want to make a question more complicated.

TCP/IP is a async protocol, but due to the Berkley Connection engine it
keeps track of what was send and received and what was not, so when there is a packet loss it will send again.
So a socket keeps the data sequential, and if we are optimistic, the only
thing that can go wrong is a socket error.

There are three stadiums(simpli fied):
(A) My object sends to the Winsock, (buffer is being fed, no data on the
network, no data on the remote point)
(B) Winsock processes his buffer and sends on the network and waits for a
confirment that the package is succesfull transmitted(buf fer is 'empty',
data on the network, no data on the remote point)
(C) All data is correctly processed and transported (buffer is truely empty, no data on the network,data on the remote point)

Relative to the Sample case:
I achieve (A) ofcourse, I would really want to know (C), but I would be
satisfied with (B). I know (B) can be achieved, I hope (C) is too.

VB.NET FrameWork 2003(all patched and updated):
I use the System.Net.Sock ets to send/receive data (no
tcpclient/tcplistener), I made a receivethread in my wrapper, the
receivethread loops/sleeps while waiting for data and then fires a
datareceived event.
Within the waitingloop there is a timeout function but this doesn't work
properly (It will never timeout).
When I send by System.Net.Sock ets.Socket.Send (buffer()) (<--this can be
10Mb) then it imitially returns to my thread, so the (internal) Send method buffers it.
The System.Net.Sock ets.Socket is a wrapper around the Win32 Socket 2 API's, it makes internal calls to those api's, so I started reading if they forgot implementing some functions, but they are all implemented.

I tried:
- The beginSend/EndSend (Async way with callback when command is finished)
This calls within the async object the Socket.Send method, so its no
help, I can better do Socket.Send myself.
- The Socket.Blocking Property, it only blocks the Receive method,
Socket.Send goes directly in the buffer and then it returns immitially.
- Socket.Poll Method, returns the accessrights of the socket, "may I use
this socket to write?"
-
getSocketOption (Socket/TCP/IP,SendBuffer/ReceiveBuffer/SendLowWater/ReceiveL owWater/SendTimeout/ReceiveTimeout) Method
Throws an Exception

MyWrapper.vb:
Imports System
Imports System.Net
Imports System.Net.Sock ets
Imports System.IO
Imports System.Collecti ons
Imports System.Threadin g
Imports System.Diagnost ics

Public Class SmartConnection
Public Event ConnectionOpene d(ByVal pMe As SmartConnection )
Public Event DataReceived(By Val pMe As SmartConnection , ByVal Data As
Message)
Public Event CouldntConnect( ByVal pMe As SmartConnection )
Public Event ConnectionClose d(ByVal pMe As SmartConnection )
Public Event [Error](ByVal pMe As SmartConnection , ByVal pErr As
Exception)
Public Event TimeOut(ByVal pme As SmartConnection )

Private _Socket As Socket
Private _ReadThread As Thread
Private _StopThread As Thread 'Lookup threadingpool
Private _Closing As Boolean = False
Private _InError As Boolean = False
Private _lport As Long
Private lasttimeout As Long
Private pHost As String
Private pPort As Long
Private pRead As Boolean
Private pTimeout As Long
Private _Iswriting As Boolean = False

Protected Overrides Sub Finalize()
_ReadThread = Nothing
_StopThread = Nothing
_Socket = Nothing
MyBase.Finalize ()
End Sub

#Region " Properties"
Public ReadOnly Property IsClosing() As Boolean
Get
IsClosing = (_Closing Or _Socket Is Nothing)
End Get
End Property

Public ReadOnly Property Connected() As Boolean
Get
Try
Connected = ((Not IsClosing) AndAlso _Socket.Connect ed =
True)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Protected ReadOnly Property Receiving() As Boolean
Get
Try
If Not Connected Then Throw New Exception("Sock et is not
connected")
Receiving = ((Not _ReadThread Is Nothing) AndAlso
_ReadThread.IsA live)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Public ReadOnly Property IPlocal() As String
Get
Try
If Connected Then IPlocal = EP2IPS(_Socket. LocalEndPoint)
Catch e As Exception
OnError(e)
End Try
End Get
End Property

Public ReadOnly Property IPremote() As String
Get
Try
If Connected Then IPremote = EP2IPS(_Socket. RemoteEndPoint) Catch e As Exception
OnError(e)
End Try
End Get
End Property
#End Region
#Region " Connect"
Public Overridable Sub ConnectTo(ByRef hostName As String, ByRef port As Long, Optional ByVal timeout As Long = 0)
Try
StartConnect(ho stName, port, timeout, True)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub ConnectToWithou tReading(ByRef hostName As String, ByRef
port As Long, Optional ByVal timeout As Long = 0)
Try
StartConnect(ho stName, port, timeout, False)
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub StartConnect(By Ref hostName As String, ByRef port As Long,
ByRef timeout As Long, ByRef read As Boolean)
Try
If Not _ReadThread Is Nothing Then Throw New Exception("Alre ady trying to connect")
_ReadThread = New Thread(AddressO f ConnectThread)
pHost = hostName : pPort = port : pRead = read : pTimeout =
timeout
_ReadThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub ConnectThread()
Try
If pHost = "" Then Throw New ArgumentNullExc eption("hostnam e")
If pPort < IPEndPoint.MinP ort Or pPort > IPEndPoint.MaxP ort Then Throw New ArgumentOutOfRa ngeException("p ort", "ArgRange_Port" )
_Socket = New Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p)
Try
_Socket.Blockin g = True
_Socket.Connect (New
IPEndPoint(Dns. Resolve(pHost). AddressList(0), pPort))
_lport = CType(_Socket.L ocalEndPoint, IPEndPoint).Por t
If Not pRead Then
SetReadName("SC .Read[PreConnect]")
_ReadThread = Nothing
Else
SetReadName("SC .EarlyRead[" & _lport & "]")
End If
OnConnectionOpe ned()
If pRead Then Receive()
Catch e As SocketException 'e.ErrorCode = 10061
SetReadName("SC .Read[NoConnect]")
_ReadThread = Nothing
OnCouldntConnec t()
Close()
End Try
Catch e As Exception
SetReadName("SC .Read[Error]")
_ReadThread = Nothing
OnError(e)
End Try
End Sub
#End Region
#Region " Receive"
Protected Sub StartReceive()
Try
If Receiving Then Throw New Exception("Rece iving was already
started")
_ReadThread = New Thread(AddressO f Receive)
SetReadName("SC .LateRead[" & _lport & "]")
_ReadThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub Receive()
Dim i As Long
Dim b() As Byte
'Dim ds As String, dt As String
Try
Do While Connected
If pTimeout > 0 Then lasttimeout = CurrTick() + pTimeout
Do While _Socket.Availab le = 0
'dt = ds
'ds = "@" & _lport & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket, SocketOptionNam e.SendBuffer) & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket, SocketOptionNam e.SendLowWater) & ","
'ds += _Socket.GetSock etOption(Socket OptionLevel.Soc ket, SocketOptionNam e.SendTimeout)
'Debug.WriteLin eIf(dt <> ds, ds)
_ReadThread.Sle ep(ReceiveWait)
If IsClosing Then Exit Sub
If _Socket.Poll(0, SelectMode.Sele ctError) Then

'System.Runtime .InteropService s.Marshal.GetLa stWin32Error())
'_Socket.GetSoc ketOption(Socke tOptionLevel.IP ,
SocketOptionNam e.Error)
OnError(New Exception("Sock et Error"))
End If
If pTimeout > 0 Then
'If _Socket.Poll(0, SelectMode.Sele ctWrite) Then
'lasttimeout = CurrTick() + pTimeout
'Else
If lasttimeout <= CurrTick() Then
OnTimeOut()
Close()
Exit Sub
End If
'Endif
End If
Loop
ReDim b(_Socket.Avail able - 1)
'SyncLock _Socket
i = _Socket.Receive (b, SocketFlags.Non e)
'End SyncLock
If i < b.Length Then ReDim b(i - 1)
OnMessageReceiv ed(New Message(b))
b = Nothing
Loop
Catch e As ThreadAbortExce ption
Exit Sub
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region
#Region " Send"
Public Overridable Overloads Sub Send(ByRef data As String)
Try
Send(getbytes(d ata))
Catch e As Exception
OnError(e)
End Try
End Sub

Public Overridable Overloads Sub Send(ByRef data() As Byte)
Try
If Not Connected Then Throw New Exception("Sock et isn't
connected")
_Iswriting = True
'SyncLock _Socket
_Socket.Send(da ta)
'End SyncLock
_Iswriting = False
Catch e As Exception
_Iswriting = False
OnError(e)
End Try
End Sub
#End Region
#Region " Close"
Public Overridable Sub Close() 'OR QUEE IT?
Try
If IsClosing Then Throw New Exception("Alre ady is closing")
_Closing = True
_StopThread = New Thread(AddressO f DoClose)
_StopThread.Nam e = "SC.Stop[" & _lport & "]"
_StopThread.Sta rt()
Catch e As Exception
OnError(e)
End Try
End Sub

Private Sub DoClose()
Try
_StopThread.Sle ep(CloseWait)
Try
If Not _ReadThread Is Nothing Then
SetReadName("SC .Read[Close]")
If _ReadThread.IsA live Then _ReadThread.Abo rt()
End If
Catch e As Exception
End Try
Try
If Not _Socket Is Nothing AndAlso _Socket.Connect ed Then
_Socket.Close()
Catch e As Exception
End Try
_ReadThread = Nothing
_Socket = Nothing
_Closing = False
_StopThread = Nothing
OnConnectionClo sed()
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region
#Region " OnEvent"
Protected Overridable Sub OnError(ByRef pErr As Exception) 'If 2 errors in diff threads?
Try
If Not _InError Then
_InError = True
Close()
_InError = False
End If
RaiseEvent Error(Me, pErr)
Catch e As Exception
Throw e
End Try
End Sub

Protected Sub OnTimeOut()
Try
RaiseEvent TimeOut(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnCouldntConnec t()
Try
RaiseEvent CouldntConnect( Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnConnectionClo sed()
Try
RaiseEvent ConnectionClose d(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnConnectionOpe ned()
Try
RaiseEvent ConnectionOpene d(Me)
Catch e As Exception
OnError(e)
End Try
End Sub

Protected Sub OnMessageReceiv ed(ByRef data As Message)
Try
RaiseEvent DataReceived(Me , data)
Catch e As Exception
OnError(e)
End Try
End Sub
#End Region

Private Sub SetReadName(ByR ef pName As String)
If Not _ReadThread Is Nothing AndAlso _ReadThread.Nam e Is Nothing
Then _ReadThread.Nam e = pName
End Sub

End Class

Jul 21 '05 #2
.....
There are three stadiums(simpli fied):
(A) My object sends to the Winsock, (buffer is being fed, no data on the
network, no data on the remote point)
(B) Winsock processes his buffer and sends on the network and waits for a
confirment that the package is succesfull transmitted(buf fer is 'empty',
data on the network, no data on the remote point)
(C) All data is correctly processed and transported (buffer is truely

empty,
no data on the network,data on the remote point)

Relative to the Sample case:
I achieve (A) ofcourse, I would really want to know (C), but I would be
satisfied with (B). I know (B) can be achieved, I hope (C) is too.


From this high level descriptions of the problem, I would create a
Application level Msg/Ack handshake to truely make
sure the remote is responding to my local requests.

I don't think peeking into the TCP stack at one system can give
your enough info to confirm the data get to the remote.

--
Browse source code and document for .NET CLI, Mozilla, Apache, NetBSD at
http://www.slink-software.com?E=SLinkEvn_1004
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2284
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
13
3380
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
12
17082
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested. This is okay in some cases (such as <tbody>), but problematic for other tags (such as <option>). Some tags (td, th, ...) do not produce warnings when...
2
26613
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as empty elements in the XML. How to do that ? I don't understand why there is no simple option to specify the output format, or did I miss something ? ...
2
1567
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, This looks like a long mail, but at the end of this post is my socket wrapper attached. I want to make a timeout procedure that starts counting down after the socketbuffer is empty. This connection is being used to transmit data following a RFC so I cann't create a control protocol that tells me the data was...
11
4583
by: Dan Bass | last post by:
which one do you use and why? MyString == null || MyString == "" vs MyString == null || MyString.Length == 0
2
2009
by: Bob Stearns | last post by:
I thought that the given expression was always TRUE if "not_there" wasn't among the keys (or subscripts if you will) of $_SESSION. Below find a dump of $_SESSION, a small snippet of code and the results. I really don't understand. A new pair of eyes may be able to spot what should be an obvious bug. Thanks for looking. _SESSION=array...
14
2327
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
26
2740
by: anonieko | last post by:
In the past I always used "" everywhere for empty string in my code without a problem. Now, do you think I should use String.Empty instead of "" (at all times) ? Let me know your thoughts.
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7918
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.