473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to get sockets accepting port

Im trying to make a wrapper and need to return the local port that the new
connection/socket is being made on. The following code the RaiseEvent, the
tmpsoc.localPort is returned as 0. How do I get the localport the server is
going to be handling the new connection?

Private Sub acceptCallback(ByVal ar As IAsyncResult)

Try
Try
Dim tmpsoc As clsSocket = New clsSocket(socket.EndAccept(ar))
RaiseEvent onAccept(tmpsoc.localPort, tmpsoc)
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

beginAccept()
Catch e As SocketException
doError(Err.Number, Err.Description)
Catch e As ObjectDisposedException
Close()
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

End Sub
Nov 21 '05 #1
2 1168
as a server listened u have to write ur owned port number b4 u sending
out ur port number to client.
i give u site to make u understanding.
http://www.developerfusion.com/show/3997/4/
regsrds

Mitch Mooney wrote:
Im trying to make a wrapper and need to return the local port that the new
connection/socket is being made on. The following code the RaiseEvent, the
tmpsoc.localPort is returned as 0. How do I get the localport the server is
going to be handling the new connection?

Private Sub acceptCallback(ByVal ar As IAsyncResult)

Try
Try
Dim tmpsoc As clsSocket = New clsSocket(socket.EndAccept(ar))
RaiseEvent onAccept(tmpsoc.localPort, tmpsoc)
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

beginAccept()
Catch e As SocketException
doError(Err.Number, Err.Description)
Catch e As ObjectDisposedException
Close()
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

End Sub


Nov 21 '05 #2
Umm, yes I have called socket.Bind(New IPEndPoint(IPAdress.Any,port) ):
socket.Listen(5). I do make an connection with the client however the socket
that is returned by the socket.EndAccept(ar) method the localport property
is 0. It should not be 0, it should be the localport of the server machine
that the new connection is going to end up communicating on.

"Supra" <su*****@rogers.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
as a server listened u have to write ur owned port number b4 u sending
out ur port number to client.
i give u site to make u understanding.
http://www.developerfusion.com/show/3997/4/
regsrds

Mitch Mooney wrote:
Im trying to make a wrapper and need to return the local port that the new
connection/socket is being made on. The following code the RaiseEvent, the
tmpsoc.localPort is returned as 0. How do I get the localport the server
is going to be handling the new connection?

Private Sub acceptCallback(ByVal ar As IAsyncResult)

Try
Try
Dim tmpsoc As clsSocket = New clsSocket(socket.EndAccept(ar))
RaiseEvent onAccept(tmpsoc.localPort, tmpsoc)
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

beginAccept()
Catch e As SocketException
doError(Err.Number, Err.Description)
Catch e As ObjectDisposedException
Close()
Catch e As Exception
doError(Err.Number, Err.Description)
End Try

End Sub

Nov 21 '05 #3

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

Similar topics

0
by: Tom Brown | last post by:
Hi, I created a win32 service for XPPro called N4010ATestService.py (see below). The service runs as a particular user with administrative rights. It starts a thread that creates a simple socket...
1
by: Dan | last post by:
I have a problem and I don't quite know how to implement the solution. I'll have a server application that will listen on a tcp port and make many similtaneous connections to remote clients. ...
4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
6
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
3
by: Michael Maercker | last post by:
hi! i'm really not into networking at all and have now been asigned the task of porting a vb6-code into vb.net (compact framework, in this case) and the code uses the winsock-control. i quickly...
2
by: dariophoenix | last post by:
Hi, I am trying to encapsulate Linux sockets and POSIX threads in C++ classes (I work in Knoppix, using KDevelop). Since sockets and threads are new to me, I searched for example code and found...
1
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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
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
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...
0
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...

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.