473,545 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listening on multiple ports

I am trying to write a vb.net socket application which listens for clients on two ports simultaneously. Is it possible to do so and how can this be done.

Please help.
Jun 27 '08 #1
5 4404
On Jun 26, 11:33*am, rome ez wrote:
I am trying to write a vb.net socket application which listens for clients on two ports simultaneously. Is it possible to do so and how can this be done.
Given that you're writing it in VB.NET, I'm not entirely clear why
you're posting on a C# newsgroup.
However, I'd just create two TcpListeners and call
BeginAcceptTcpC lient on each of them.

Where are you having difficulties?

Jon
Jun 27 '08 #2
rome ez wrote:
I am trying to write a vb.net socket application which listens for clients on two ports simultaneously. Is it possible to do so and how can this be done.

Please help.
If you can do it with one, you can do it with two. You instantiate a socket (or
more likely a TcpListener), start it listening. Then repeat.

Typically there is some kind of while loop involved with listening for client
connections. So my personal approach would be to create a class which manages
each socket within its own thread. (A plus which may or may not matter to you
is that you then have the option within your loop to use the simple synchronous
methods which block immediately, such as AcceptSocket(). ) But what have you
actually tried that is not working and where does the difficulty occur?

(This is not a VB news group, however. Examples you get here will most likely
be in C#. If your problem is syntax related you might consider moving to a VB
group.)

Hope this helps,
-rick-
Jun 27 '08 #3
rome ez wrote:
I am trying to write a vb.net socket application which listens for
clients on two ports simultaneously. Is it possible to do so and how
can this be done.
Obviously that is possible.

The easiest approach is possible just two threads each listening
on one port.

Arne
Jun 27 '08 #4
On Jun 26, 6:33*am, rome ez wrote:
I am trying to write a vb.net socket application which listens for clients on two ports simultaneously. Is it possible to do so and how can this be done.

Please help.
Hi,

This is a C# NG, you should ask VB question in the correct group.

Yes, you can do it, just create two threads with the correct port
number,
Each connection should also generate a new thread, this will let you
have multiple clients for a port at the same time
Jun 27 '08 #5
On Thu, 26 Jun 2008 03:33:33 -0700, rome <ezwrote:
I am trying to write a vb.net socket application which listens for
clients on two ports simultaneously. Is it possible to do so and how can
this be done.
In addition to all of the other replies (which all accurately explain that
dedicating a single thread to each listening socket, plus one thread per
connection), I will point out that the "simplest approach" is only
suitable for relatively small numbers of listeners and connections. Once
you get into the hundreds of connections, you'll want to switch to
something more efficient, which in .NET is basically the asynchronous
methods (i.e. the methods that start with "Begin..." and "End...")

Pete
Jun 27 '08 #6

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

Similar topics

1
4826
by: Jim Kipp | last post by:
Hi I am writing a simple server to monitor ports. The problem is I don't know how to make it listen on multiple ports. It creates the first socket, listens, than accepts and of course the accept call blocks, so it does not return to create socket for the other ports. I am doing this in windows, so using 'fcntl' to do non blocking won't work....
5
9936
by: lazydb2dba | last post by:
I would like to know if there is any reason that a connection port is not listening. I've found the following message in my db2diag.log DIA3003E Error encountered in "TCPIP" protocol support. Return code from "sqleGetAgent" was "-6036". Other findings are: 1. The result of "netstat -an|grep LISTEN" doesn't show the connection
3
2354
by: ssantamariagarcia | last post by:
I am trying to program a server in C for UNIX to get a kind of "bridge" between the clients of a port A and the clients of a port B. For that, I create 2 processes: one that listen the requests of port A clients and another for the Port B ones. In each process, when a connetion service is required, after accepting , the value of the socket...
6
3096
by: kai | last post by:
Hi, I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get this message: "ASP.NET Development Server faild to start listening port 1034. Error message: An attempt was made to access a socket in a way fobidden by its access permissions."
7
3722
by: Matt | last post by:
I have approximately 5 instances on my test server that are identical to my prod server. On the prod server, when I look at the services file, there is a single entry per instance and everything seems to be working fine. However, on the test server, after creating each instance, there are 4 entries per instance. Is there a need for all 4...
3
3378
by: tshad | last post by:
I have been trying to run IIS and Apache Tomcat on the same Server using the same Port (80 for http and 443 for https). I am trying to do this by using multiple IP address on the same Nic card. This would allow me multiple sockets for the same port. With all my research it seems that most services seem to listen on ALL IP addresses on the...
1
3620
by: jcprince | last post by:
Hi Not sure I can do what I'm trying to do without using a 3rd party component like Dart. I need to build a windows service to create a socket connection on an IBM mainframe using an IP and port combination. No problem there. However, due to the expected volume (at least 20x10K streams per second in each direction), the mainframe sysadmin...
5
1601
by: =?Utf-8?B?SmVzc2VlIEhvbG1lcw==?= | last post by:
I'm not sure I'm going about this the right away, and I've attempted to search every online topic that I can which makes me think this is not possible or I'm simple coding this incorrectly. What I'd like to do is this: 1) See hot many COM ports are on a computer: foreach (string port in SerialPort.GetPortNames()) .... 2) Uniquely and...
27
2101
by: cmdolcet69 | last post by:
Can anyone tell me if its possible to do multiple event args in vb.net?
0
7486
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...
1
7442
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
6001
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5347
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
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...
1
1905
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
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
729
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.