aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Java net BindException:Address already in use: JVM_Bind Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java net BindException:Address already in use: JVM_Bind" Watch "Java net BindException:Address already in use: JVM_Bind" New topic
Author

Java net BindException:Address already in use: JVM_Bind

kimi lynn
Greenhorn

Joined: Jun 02, 2003
Posts: 27
Hello,
I've written a client/server program to start matlab on the server and its working fine and also written another client/server program to transfer files from client machine to server.Both these programs are working fine when they are executed separetely.Now, I combined these 2 server programs into one and when i try to run the application, it throws me with the following error:
Java.net.BindException:Address already in use: JVM_Bind.
I guess this is because both the server programs are listening on port 1234.If I change the port in the MatlabRCServer program, I'm able to transfer a file and when I try to start matlab, the client application hangs up.I had to quit forcibly.
Any ideas where the code is messed up???
Thanks in advance.

The following are the 2 separate server programs:
server program to start matlab

server program to send a file

[ February 12, 2004: Message edited by: kimi lynn ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

Originally posted by kimi lynn:

I guess this is because both the server programs are listening on port 1234.

You are correct. As for your other problem, I think you posted the same code twice.


[How To Ask Questions On JavaRanch]
kimi lynn
Greenhorn

Joined: Jun 02, 2003
Posts: 27
Joe, sorry as I posted the same code twice.Now, I'm listening on different ports and now the service is waiting for the client to connect.But, Unfortunately when i try to run the matlab on the server, it does'nt respond and the client application also hangs up.As I said in my previous post, If i run alone matlabrcserver program and try to start the matlab on the server, it works fine.BUt, when i run the tcp server which is a mix of both the server programs, the application hangs up.
Any help??
I edited my first post.
Thanks in advance everybody.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

I am detecting a bit of confusion about how to use sockets. Are you trying to set any of your programs to use the same socket as the matlab server? That would cause the same bind problem you experienced before. If you are trying to connect to the matlab server, you should use a java.net.Socket.
Are you attempting to connect one of your classes to another via a socket? If that is the case, the "server" should declare a java.net.ServerSocket, which listens on a port and the "client" should use a java.net.Socket to connect to the server's port.
Also it may help those of us in the peanut gallery if you would name your classes with more expressive names. Two of them are named "tcpServer" and while they have small differences, I cannot divine the purpose of those classes from the code.
Maybe a look at the Custom Networking tutorial would help?
kimi lynn
Greenhorn

Joined: Jun 02, 2003
Posts: 27
Joe,
let me explain you clearly what exactly am trying to do.At first, I run the matlabserver program and then when i try to run the matlab on the server, it works fine.NOw, I run the file server program and try to send a file from the client.The file is getting through.So,when I test these 2 server programs separately, both are working fine for me.Now, all I want to do is to make "ONE" server program so that either I can start matlab on the server or I can send files from client to server using my GUI.
Here are the 2 server programs:
Matlab Server Program

File Transfer Server Program

and heres my client code:

I'd be glad if you/somebody can help me.
Thanks once again.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

Pardon me if I seem dense, but you are still leaving out some details. Where is the client that corresponds to MatlabRCServer? Also, you are showing us the code that works and not your "ONE" server that does not work, right?
 
 
subject: Java net BindException:Address already in use: JVM_Bind