Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Reserving sockets

Thread view: 
Roedy Green - 21 Oct 2007 13:02 GMT
Is there a mechanism either in Java or in Windows to reserve a socket?

Is there a mechanism to find out if a socket is in use by some other
program?

If you are a programmer, how do you go about deciding what socket to
use for some non-standard protocol?

Is this just something you expect the user to configure?

It turns out JetBrains IntelliJ Idea and something else that I have
not yet determined are fighting over the same sockets in the 6944
range.

PS. what is the best PCI Ethernet card, fast, rock solid drivers for
Vista and Ubuntu?

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 21 Oct 2007 13:33 GMT
On Sun, 21 Oct 2007 12:02:34 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>Is there a mechanism to find out if a socket is in use by some other
>program?

I found this tool for Windows:

REM find out who is using which TCP/IP sockets
netstat -o

rem you might get a result like this:
rem Proto  Local Address          Foreign Address        State PID
rem TCP    192.168.0.101:49181    209.34.241.67:http     ESTABLISHED
4908

Rem you can then get more information about what that PID means
TaskList /o

too see without wrap, see http://mindprod.com/jgloss/tcpip.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

RedGrittyBrick - 21 Oct 2007 14:36 GMT
> Is there a mechanism either in Java or in Windows to reserve a socket?

Without binding to it?

> Is there a mechanism to find out if a socket is in use by some other
> program?

You already know about netstat. Another tool is SysInternals TCPView.
The obvious way from Java is to attempt to bind to it.

> If you are a programmer, how do you go about deciding what socket to
> use for some non-standard protocol?

AIUI, a "socket" is the combination of a transport level protocol (e.g.
UDP or TCP), an IP-address and a port number. Therefore I'm assuming you
mean "how do I choose a TCP or UDP port number for my application?"

I'd read this, especially the first few paragraphs:
http://www.iana.org/assignments/port-numbers
It may also be interesting to grep it for "any private"?

If I was in a huge corporation planning a product I expected to become
very widely used (i.e. by millions of computers on the Internet) then I
suppose I'd try applying to IANA for a reserved port.

> Is this just something you expect the user to configure?

I'd have a carefully chosen default but allow the user to configure it.

> It turns out JetBrains IntelliJ Idea and something else that I have
> not yet determined are fighting over the same sockets in the 6944
> range.

IRC? Good luck!

> PS. what is the best PCI Ethernet card, fast, rock solid drivers for
> Vista and Ubuntu?

No idea, I'd pick a popular and well-known brand. E.g. Intel Gigabit.

I feel I have probably added nothing to your existing knowledge, sorry
about that :-)
Roedy Green - 23 Oct 2007 08:34 GMT
On Sun, 21 Oct 2007 14:36:55 +0100, RedGrittyBrick
<RedGrittyBrick@SpamWeary.foo> wrote, quoted or indirectly quoted
someone who said :

>No idea, I'd pick a popular and well-known brand. E.g. Intel Gigabit.

that's what I got. Intel has a feature that appeals, a common driver
for all its models.  That strikes me then as more likely the card will
be supported for a long time to come and the driver will be bug-free.

Now to see if it clears up the weird TCP/IP locking problems.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Martin Gregorie - 21 Oct 2007 15:37 GMT
> Is there a mechanism either in Java or in Windows to reserve a socket?

I look at my /etc/services file, but then I run Linux. There's a
regularly updated list of port numbers at

http://www.iana.org/assignments/port-numbers

This replaces RFC 1700, which formerly contained the definitive list.

> Is there a mechanism to find out if a socket is in use by some other
> program?

netstat

It is available for *NIX systems and NT-based Windows systems, so it
should be available from Win 2K onwards. Use the -n option to see port
numbers: otherwise it shows the service name. Use -p to see the program
name and PID.

> If you are a programmer, how do you go about deciding what socket to
> use for some non-standard protocol?

I've noticed that the low 16000s are unused and tend to use those in
sequence so my servers don't clash.

> Is this just something you expect the user to configure?

I assign a default port but make the port number configurable, via a
configuration file, command line option or both. If both, the command
line option overrides the config file.

Many common programs, both open source and proprietary, are written with
a default and configurable override. This includes most database and web
servers. Its essential for these to have configurable ports because its
not uncommon to run multiple copies on a server. Their clients must also
use configurable port assignments.

> It turns out JetBrains IntelliJ Idea and something else that I have
> not yet determined are fighting over the same sockets in the 6944
> range.

According to the IANA database 6944 is unassigned, so imagine my
surprise. I hope their port assignments are configurable.

> PS. what is the best PCI Ethernet card, fast, rock solid drivers for
> Vista and Ubuntu?

I used to swear by 3COM and at Linksys. My only, seldom used,
Windows/Linux dual boot box has still got a 10 year old 3COM 10mb card
in it which has never given trouble.

This laptop has a D-Link DFE-670TXB PCMCIA card and my house server has
a RealTek RTL8139 installed. The D-Link and Realtek are both dual speed
10/100 devices and both have been trouble free for 2-3 years. My LAN is
based on a D-Link hub which has 'just run' for about 8 years.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Lew - 21 Oct 2007 16:15 GMT
Roedy Green wrote:
>> PS. what is the best PCI Ethernet card, fast, rock solid drivers for
>> Vista and Ubuntu?

> I used to swear by 3COM and at Linksys. My only, seldom used,
> Windows/Linux dual boot box has still got a 10 year old 3COM 10mb card
[quoted text clipped - 4 lines]
> 10/100 devices and both have been trouble free for 2-3 years. My LAN is
> based on a D-Link hub which has 'just run' for about 8 years.

Realtek makes the motherboard-embedded NIC on my machine, an AMD-64-based
machine.  No worries, but then, I'm dual-booting Fedora Core 7 and Win XP, not
the OSes of Roedy's concern.

Signature

Lew

Martin Gregorie - 22 Oct 2007 13:52 GMT
> Roedy Green wrote:
>>> PS. what is the best PCI Ethernet card, fast, rock solid drivers for
[quoted text clipped - 12 lines]
> AMD-64-based machine.  No worries, but then, I'm dual-booting Fedora
> Core 7 and Win XP, not the OSes of Roedy's concern.

My IBM Netvista (866 MHz, PIII) has a Realtek card in it which is
slightly surprising. I would have expected it to be on the motherboard.
It runs FC6 +J2SE 1.4 and will be upgraded to FC7 + JSE 6 when I get a
round tuit.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Lew - 22 Oct 2007 14:11 GMT
> My IBM Netvista (866 MHz, PIII) has a Realtek card in it which is
> slightly surprising. I would have expected it to be on the motherboard.
> It runs FC6 +J2SE 1.4 and will be upgraded to FC7 + JSE 6 when I get a
> round tuit.

I don't remember mobos with integrated NICs being very common, or even extant,
in P3 days.  They started being more common only in the last couple or few years.

Signature

Lew

Martin Gregorie - 22 Oct 2007 19:45 GMT
>> My IBM Netvista (866 MHz, PIII) has a Realtek card in it which is
>> slightly surprising. I would have expected it to be on the
[quoted text clipped - 4 lines]
> extant, in P3 days.  They started being more common only in the last
> couple or few years.

Its an ATX mobo and had I assumed that integrated NICs came in with the
ATX format. Shows how long it is since I bought a new system: the last
new one I bought has a baby-AT board.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Christopher Benson-Manica - 22 Oct 2007 15:15 GMT
>> It turns out JetBrains IntelliJ Idea and something else that I have
>> not yet determined are fighting over the same sockets in the 6944
>> range.
>
> According to the IANA database 6944 is unassigned, so imagine my
> surprise. I hope their port assignments are configurable.

According to the in-house IntelliJ guru, it's possible that IntelliJ
is using 6944 for its licensing enforcement, which might be why it
isn't documented anywhere.  It also sounds like it's not configurable,
unfortunately.

Signature

 C. Benson Manica    | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
  sdf.lonestar.org   | Google groups, due to rampant unchecked spam.

Christopher Benson-Manica - 22 Oct 2007 16:06 GMT
> Is there a mechanism either in Java or in Windows to reserve a socket?

ITYM "port".

> Is this just something you expect the user to configure?

That's been my general strategy, but I don't write the type of
application where that might be a real concern.

> It turns out JetBrains IntelliJ Idea and something else that I have
> not yet determined are fighting over the same sockets in the 6944
> range.

As a data point, Intellij 7 on this XP box seems not to be interested
in that port.

Signature

 C. Benson Manica    | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
  sdf.lonestar.org   | Google groups, due to rampant unchecked spam.

Roedy Green - 23 Oct 2007 20:28 GMT
On Sun, 21 Oct 2007 12:02:34 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>It turns out JetBrains IntelliJ Idea and something else that I have
>not yet determined are fighting over the same sockets in the 6944
>range.

I did a clean reinstall of Windows Vista and the problem has gone
away.  An update install did not help.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.