Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multi sockets on one port

Posted on 1999-07-28
5
Medium Priority
?
327 Views
Last Modified: 2010-04-16
every time I assign more than one socket on a single port the code compiles ok but it throws bind exceptions when I run the server.How can I overcome this ???
0
Comment
Question by:spunog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:mrquija
ID: 1247281
is it even possible to assign more than one socket to a single port? I thought each port could only handle one socket?
0
 
LVL 6

Expert Comment

by:gadio
ID: 1247282
spunog, you can not listen more than once on a port. Why do you need to listen more than once? Can you paste a piece of you code here?
0
 

Accepted Solution

by:
newcumdb earned 800 total points
ID: 1247283
Are you trying to set up a ServerSocket or a Socket?

A server socket isn't an actual open connection to another computer, it's an open port waiting on your local machine.  If you call the accept() method on a ServerSocket, it will wait until someone connects to that port.  At that point, it returns a Socket object, which is a real live connected socket.  You can call serversocket.accept() over and over again, getting as many Sockets as you want.  (as long as people keep connecting)
0
 

Author Comment

by:spunog
ID: 1247284
newcumdb,
So I just put this line in once ,
ServerSocket socket = new ServerSocket(6666, 300);
and have as many of these as I see fit for example
Socket s = socket.accept();    
Socket s1 = socket.accept();    
Socket s2 = socket.accept();    

???????????????
0
 

Author Comment

by:spunog
ID: 1247285
Fair play newcumbd,
that has worked fine
Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question