473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with this code...

Here's the situation...

I've got a working program that sends commands to various computers using
the RemoteExec service. There's one pc that doesn't seem to reply. It
accepts the connection but never replies. So my program just sits there in
a "not responding" state waiting for the reply and I have to "end-task" it.
Here's the code where it locks up. Look for the 3rd "debug.writeline" in
the code...that's where it locks up. Is there a way to have this timeout?
Or otherwise abort the function and allow the program to continue on with
the next pc in the list?

Thanks.

'Create a socket connection with the specified server & port (512 is the
remote execute port)

Dim s As Socket = connectSocket(txtRemotePC.Text, 512)

If s Is Nothing Then

MsgBox("Unable to connect to Remote PC", MsgBoxStyle.Critical)

Exit Sub

End If

'Send message to the repeater

Try

s.Send(ByteGet, ByteGet.Length, SocketFlags.None)

Catch ex As SocketException

Debug.WriteLine("s.Send: " & ex.Message)

Catch ex As Exception

Debug.WriteLine("s.Send: " & ex.Message)

End Try

'Recieve the response from the repeater

Try

Debug.WriteLine("s.Receive") <-- locks up after writing this to
the debug window.

bytes = s.Receive(RecvBytes, RecvBytes.Length, SocketFlags.None)

Debug.WriteLine("s.Receive complete") <--never gets here, never
throws an exception

Catch ex As SocketException

Debug.WriteLine("s.Receive: " & ex.message)

Catch ex As Exception

Debug.WriteLine("s.Receive: " & ex.Message)

End Try
Nov 21 '05 #1
2 1327
On Mon, 9 Aug 2004 17:53:14 -0600, Terry Olsen wrote:
Here's the situation...

I've got a working program that sends commands to various computers using
the RemoteExec service. There's one pc that doesn't seem to reply. It
accepts the connection but never replies. So my program just sits there in
a "not responding" state waiting for the reply and I have to "end-task" it.
Here's the code where it locks up. Look for the 3rd "debug.writeline" in
the code...that's where it locks up. Is there a way to have this timeout?
Or otherwise abort the function and allow the program to continue on with
the next pc in the list?

Thanks.

'Create a socket connection with the specified server & port (512 is the
remote execute port)

Dim s As Socket = connectSocket(txtRemotePC.Text, 512)

If s Is Nothing Then

MsgBox("Unable to connect to Remote PC", MsgBoxStyle.Critical)

Exit Sub

End If

'Send message to the repeater

Try

s.Send(ByteGet, ByteGet.Length, SocketFlags.None)

Catch ex As SocketException

Debug.WriteLine("s.Send: " & ex.Message)

Catch ex As Exception

Debug.WriteLine("s.Send: " & ex.Message)

End Try

'Recieve the response from the repeater

Try

Debug.WriteLine("s.Receive") <-- locks up after writing this to
the debug window.

bytes = s.Receive(RecvBytes, RecvBytes.Length, SocketFlags.None)

Debug.WriteLine("s.Receive complete") <--never gets here, never
throws an exception

Catch ex As SocketException

Debug.WriteLine("s.Receive: " & ex.message)

Catch ex As Exception

Debug.WriteLine("s.Receive: " & ex.Message)

End Try


You can set a Receive timeout value...

' all receives will timeout after 5 seconds of waiting for data...
s.SetSocketOption (SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeOut, 5000)

HTH
--
Tom Shelton [MVP]
Nov 21 '05 #2
>
You can set a Receive timeout value...

' all receives will timeout after 5 seconds of waiting for data...
s.SetSocketOption (SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeOut, 5000)


Thanks! That worked like a charm. I set the timeout to 15 minutes
tho...sometimes it takes that long for a response.
Nov 21 '05 #3

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

Similar topics

15
3652
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
19
4066
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
11
2778
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
7
3288
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
48
3183
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
4
7385
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
2
4421
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
15
4564
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
2735
by: Quas.co.ua | last post by:
Hello all. I need your help. I need C compler to make demo of some technologie. This C compiler I need to write program which after run will be located in one segment of memory and it...
20
4223
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
7260
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,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
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,...
0
7537
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...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.