473,416 Members | 1,607 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,416 software developers and data experts.

Sockets usage with vb.net

Hello !

I have some devices which communicate trough LAN to the server the old
form i was using was FTP as a communication between Server and Client i
have decided to use personal TCP sockets instead of using the FTP
protocol. Well im familar with sockets but some concepts im not able to
get it. I would be using Vb.Net as a server program but the question
pampering my brain is for eg .. ip 192.168.0.0.1 tries to communicate
on the server port 5444 and at the same time another device with ip
192.168.0.0.2 tries to communicate on port 5444 what would be the
result in this case the device with ip x.x.x.1 is still using the port
will the other device can communicate on the same port .

Regards
Altaf

Nov 23 '05 #1
10 1970
Don't you mean IP: 192.168.0.1 & not 192.168.0.0.1?

You can use one of the overloaded functions to pass a specific port number.
Just see the sockets class for information

Socket programming is greatly simplified with VB.NET

Crouchie1998
BA (HONS) MCP MCSE
Nov 23 '05 #2
al************@gmail.com wrote:
Hello !

I have some devices which communicate trough LAN to the server the old
form i was using was FTP as a communication between Server and Client i
have decided to use personal TCP sockets instead of using the FTP
protocol. Well im familar with sockets but some concepts im not able to
get it. I would be using Vb.Net as a server program but the question
pampering my brain is for eg .. ip 192.168.0.0.1 tries to communicate
on the server port 5444 and at the same time another device with ip
192.168.0.0.2 tries to communicate on port 5444 what would be the
result in this case the device with ip x.x.x.1 is still using the port
will the other device can communicate on the same port .

Regards
Altaf


This is the basic concept:

You use one port to make a connection (port 5444 in this case) then you
open a new port at a random port number (the framework will pick a port
for you) This new port is the one all the communication is done on,
leaving port 5444 for the next connection.

Chris
Nov 23 '05 #3
This is the basic concept:

You use one port to make a connection (port 5444 in this case) then you
open a new port at a random port number (the framework will pick a port
for you) This new port is the one all the communication is done on,
leaving port 5444 for the next connection.

Chris


Sorry, but I thought only UDP connections needs to release the public port
(5444 in this case), and create a random port for communication. Is the
socket for TCP and UDP connection works in same way?

Please point me out if I am wrong. Thanks.

Kai
Nov 23 '05 #4
Hello !
Thanks all for the reply....

Well i got the idea behind sockets more clearly....

Thanks once again.

Nov 23 '05 #5
> You use one port to make a connection (port 5444 in this case) then you
open a new port at a random port number (the framework will pick a port
for you) This new port is the one all the communication is done on,
leaving port 5444 for the next connection.


I'm not convinced this is true actually, at least not for TCP sockets. If
this is the case, then a webserver listening on port 80 has to create a new
socket listening on a random port each time a client connects, which
produces obvious problems with firewalls & routers.

I was under the impression you created an array of socket objects, adding to
the array each time a new client connected, but all set to the same port (or
perhaps port 0?). I could be wrong as I don't do much socket coding...

Kind Regards,
Alex Clark
Nov 23 '05 #6
It doesn't pose a problem with firewalls & routers. I'm sure someone will
correct me if i'm wrong, but this is my experience with sockets.

Client calls server on listener port (SMTP port 25 perhaps)
Server responds with a random port assignment (maybe port 9999)
This causes the router/firewall to "open" port 9999 (maybe limit it to the
client's IP)
The client responds back on port 9999 and data exchange can commence.
The server resumes listening for new connections on port 25.
"Alex Clark" <ho*******@community.nospam> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
You use one port to make a connection (port 5444 in this case) then you
open a new port at a random port number (the framework will pick a port
for you) This new port is the one all the communication is done on,
leaving port 5444 for the next connection.


I'm not convinced this is true actually, at least not for TCP sockets. If
this is the case, then a webserver listening on port 80 has to create a
new socket listening on a random port each time a client connects, which
produces obvious problems with firewalls & routers.

I was under the impression you created an array of socket objects, adding
to the array each time a new client connected, but all set to the same
port (or perhaps port 0?). I could be wrong as I don't do much socket
coding...

Kind Regards,
Alex Clark

Nov 23 '05 #7
Hi,
It doesn't pose a problem with firewalls & routers. I'm sure someone will
correct me if i'm wrong, but this is my experience with sockets.

Client calls server on listener port (SMTP port 25 perhaps)
Server responds with a random port assignment (maybe port 9999)
This causes the router/firewall to "open" port 9999 (maybe limit it to the
client's IP)
The client responds back on port 9999 and data exchange can commence.
The server resumes listening for new connections on port 25.


I'm 99% certain firewalls & routers do NOT work that way, it would pose a
pretty huge security risk if they were to open ports like that based on the
request of a service within the network.

The server itself likely remaps the established connection to either a
random port or a "pseudo" port (ie port 0) and then resumes listening on
port 25 in your example, otherwise the routers would potentially have large
arrays of open ports on them during busy times.

Regards,
Alex Clark
Nov 23 '05 #8
I can only go by what I observe watching incoming TCP connections to my BBS.
I am inside a router. The BBS listens on port 9999 (I have the router
configured to send 9999 to my BBS's internal IP). When a user logs in, the
status screens shows a user connected on some random port such as port
19837. I don't have that port opened up on my router, but the
communications are not interrupted.

If the server "remapped" the connection to a random port, wouldn't the
actual connection still be on port 9999? If so, how would anyone else be
able to connect? When I telnet out to another site, I telnet to a specific
port (23 for instance). Once the connection is established, my client
program tells me I am connected to some random port like 1029.

So from my observations, my explanation makes the best sense to me.

"Alex Clark" <ho*******@community.nospam> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Hi,
It doesn't pose a problem with firewalls & routers. I'm sure someone
will correct me if i'm wrong, but this is my experience with sockets.

Client calls server on listener port (SMTP port 25 perhaps)
Server responds with a random port assignment (maybe port 9999)
This causes the router/firewall to "open" port 9999 (maybe limit it to
the client's IP)
The client responds back on port 9999 and data exchange can commence.
The server resumes listening for new connections on port 25.


I'm 99% certain firewalls & routers do NOT work that way, it would pose a
pretty huge security risk if they were to open ports like that based on
the request of a service within the network.

The server itself likely remaps the established connection to either a
random port or a "pseudo" port (ie port 0) and then resumes listening on
port 25 in your example, otherwise the routers would potentially have
large arrays of open ports on them during busy times.

Regards,
Alex Clark

Nov 23 '05 #9
Hi Terry,

As I said, I'm certainly no socket expert! I think you're right with it
assigning to another random port - my experiences were from the "old" days
of VB6 Winsock programming. I believe once it's connected on the "true"
port, ie 25 for an SMTP server, the socket object referenced by handle is
then remapped to a new port number. Because it's already an established
TCP/IP connection, the router/firewall continues to let it through on the
new port.

Dang IP layer theories never did sit well with me, hehe!

Kind regards,
Alex Clark
"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I can only go by what I observe watching incoming TCP connections to my
BBS. I am inside a router. The BBS listens on port 9999 (I have the router
configured to send 9999 to my BBS's internal IP). When a user logs in, the
status screens shows a user connected on some random port such as port
19837. I don't have that port opened up on my router, but the
communications are not interrupted.

If the server "remapped" the connection to a random port, wouldn't the
actual connection still be on port 9999? If so, how would anyone else be
able to connect? When I telnet out to another site, I telnet to a
specific port (23 for instance). Once the connection is established, my
client program tells me I am connected to some random port like 1029.

So from my observations, my explanation makes the best sense to me.

"Alex Clark" <ho*******@community.nospam> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Hi,
It doesn't pose a problem with firewalls & routers. I'm sure someone
will correct me if i'm wrong, but this is my experience with sockets.

Client calls server on listener port (SMTP port 25 perhaps)
Server responds with a random port assignment (maybe port 9999)
This causes the router/firewall to "open" port 9999 (maybe limit it to
the client's IP)
The client responds back on port 9999 and data exchange can commence.
The server resumes listening for new connections on port 25.


I'm 99% certain firewalls & routers do NOT work that way, it would pose a
pretty huge security risk if they were to open ports like that based on
the request of a service within the network.

The server itself likely remaps the established connection to either a
random port or a "pseudo" port (ie port 0) and then resumes listening on
port 25 in your example, otherwise the routers would potentially have
large arrays of open ports on them during busy times.

Regards,
Alex Clark


Nov 23 '05 #10
Hello !

Well i have also observed the same thing. The port binds itself to a
different port which can be seen using netstat -a command where the
address is bind to a foregin address i gone trough it i have some more
questions

I want to create a server program where Server listens to a specific
port take it 8000 there would be many clients who may need to connect
to this port same time so it's taken care and been discussed above, now
suppose one client ask's 1+1 to server and at same time other client
initates a connection and asks server 9*2 server is ready with answers
but the point is the answer needs to be send to specific client whom it
belongs the connection for both the clients is active how can we send
the answer back to the respective clients. I gone trought the
NetworkStream class in vb.net but still im confused how can this be
done.

Regards
Altaf

Dec 1 '05 #11

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

Similar topics

6
by: Anatoly | last post by:
In our application I need to detemine if there is a internet connection valid. So I build a windows service which every minute creates telnet connection against some host and port. If I do...
11
by: Bonj | last post by:
I've been following a socket programming tutorial to make a simple TCP communication program, seemingly without hitches, it appears to work fine. However the structure of it is to have a server...
9
by: Bonj | last post by:
I've been following a socket programming tutorial to make a simple TCP communication program, seemingly without hitches, it appears to work fine. However the structure of it is to have a server...
3
by: J C | last post by:
Hi, I'm using UDPClient to make a simple DNS server. I notice that intermittently and unpredictibly I get: Unhandled Exception: System.Net.Sockets.SocketException: An existing connection...
5
by: Dan Ritchie | last post by:
I've got a client/server app that I used to send large amounts of data via UDP to the client. We use it in various scenarios, one of which includes rendering a media file on the client as it is...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.