SocketExceptopn: Socket Operation on nonsocket: JVM_Bind - what ?
Hi,
I'm a new Java-application developer. I'm stadying Java at university in Kassel (germany) an now in university holiday I wnat to development a little messanging tool. So I have tried some basic technics.... but the simplesed things won't work!
I've wrote this code:
import java.net.*;
import java.io.*;
class MulClient
public static void main( String args[] ) throws IOException
Socket server = new Socket("localhost", 450 );
But if I complie the code an run it....the JVM throws an Exception:
Exception in thread "main" java.net.SocketException: Socket operation on nonsocket: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.Socket.bind(Socket.java:553)
at java.net.Socket.<init>(Socket.java:363)
at java.net.Socket.<init>(Socket.java:178)
at MulClient.main(MulClient.java:8)
I'm using windows xp Sp1 an a firewall (kerio personal firewall), ie 6 sp1....I'm behind a router but protocolls such as TCP/ip are installed..of course....
Excause me bad english.....
Thanks!
Faithfully MrSandman
Hi,
1) You haven't created a ServerSocket so nothing's
listening on that port. I doubt this is it, as it
would probabl time out.If I start the server class-file (changed port 1044):
import java.net.*;
import java.io.*;
public class MulServer
public static void main( String args[] ) throws IOException
ServerSocket server = new ServerSocket( 1044 );
while ( true )
Socket client = server.accept();
InputStream in = client.getInputStream();
OutputStream out = client.getOutputStream();
int start = in.read();
int end = in.read();
int result = start * end;
out.write( result );
client.close();
}the same exception appears. So there can't be a server listining on that port. But why doesn't this work?
on MS developers page the exception or winsocket error is explained:
"An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid."
But I don't understand; what does this mean?
2) There is a server/listener type dealy bound to
that port, but it's a FIFO or named pipe or
something, rather than a Socket.What? do you think there is another application running on that port. There isn't anyone.
I can't believe. I've tried another network-sample file taken from an internet tutorial...(I thought...this should work...) but the same exception....
Any ideas? Please help!
Thanks MrSandman
Similar Messages
-
Socket operation on nonsocket: recv failed
I get this Exception when operating with Socket : Socket operation on nonsocket: recv failed
What does this exception mean?Looking on google,
http://www.google.co.uk/search?num=20&hl=en&c2coff=1&q=+Socket+operation+on+nonsocket%3A+recv+failed+&btnG=Search&meta=
this appears to be a windows error
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp -
Hi,
I have an SMSModule that:
* connects to an SMS center via a socket.
* sends an SMS.
* disconnects
* if SMS send fails then sms is put in queue and we do the whole thing
again.
This worked fine when I only did one sms. But when I put them in a queue
I got this problem.
Any hints or ideas?
//Mikael
Trace
Sending sms to queue
now waiting...
Queue is not empty sending.....
class com.lightlabs.teaching.help.lab3.SMSModule:send()
class com.lightlabs.teaching.help.lab3.SMSModule:connect()
class com.lightlabs.teaching.help.lab3.MSIPProtocolHandler:connect()
MSIPIncomingHandlerThread starting...
GOT: !LogonConf:
mSIP Kommando var: !LogonConf
CoolFlix log: MSIPProtocolHandler;setLoggedin(true)
Is the module connected? :true
CoolFlix log: MSIPProtocolHandler;sendSMS
CoolFlix log: Waiting for response from SMSC
MSIPIncomingHandlerThread starting...
GOT: SubmitConf:MsgReference=9,At=1058494566369,
mSIP Kommando var: SubmitConf
CoolFlix log: MSIPProtocolHandler:setMessageSent()
GOT:
StatusInd:MsgReference=9,Sequence=11,At=1058494567359,Originator=0046702673044,Status=buffered,Reason=0,Time=1058494567,
mSIP Kommando var: StatusInd
CoolFlix log: MSIPProtocolHandler:getMessageSent()
CoolFlix log: Message has been sent
CoolFlix log: MSIPProtocolHandler:setMessageSent()
class com.lightlabs.teaching.help.lab3.SMSModule:disconnect()
class com.lightlabs.teaching.help.lab3.MSIPProtocolHandlerdisconnect()
GOT:
StatusInd:MsgReference=9,Sequence=12,At=1058494576359,Originator=0046702673044,Status=delivered,Reason=0,Time=1058494576,
mSIP Kommando var: StatusInd
GOT: !LogoffConf:
mSIP Kommando var: !LogoffConf
CoolFlix log: MSIPProtocolHandler;setLoggedin(false)
We got LogOffConf
Waiting ......for thread to die
java.net.SocketException: Socket operation on nonsocket: JVM_recv in
socket input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:116)
at
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)
at
sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:445)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:179)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReaMSIPIncomingHandlerThread dying...
der.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at
com.lightlabs.teaching.help.lab3.MSIPIncomingHandlerThread.run(MSIPIncomingHandlerThread.java:31)
java.net.SocketException: Socket operation on nonsocket: JVM_recv in
socket input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:116)
at
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)
at
sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:445)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:179)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at
com.lightlabs.teaching.help.lab3.MSIPIncomingHandlerThread.run(MSIPIncomingHandlerThreaMSIPIncomingHandlerThread
dying...
d.java:31)
Queue is not empty sending.....Hi,
I just provided the output trace. I have a zip file with the code I am using and it is a bit to much to copy and paste. I am willing to send you the code in a zip if you would like to look at it.
Basically in my SMSModule I start a thread that that checks if a queue has an sms. If It has an sms then we do send().
Send () --> connect(), sendSMS(),disconnect()
For some reason the is a problem when we disconnect.
Any ideas?
//Mikael
SMSModule.java
public class SMSModule extends Thread{
public static final int MSIP_PROTOCOL=1;
public static final int SMPP_PROTOCOL=2;
private static SMSModule instance;
//Properties
private String protocol = null;
private String host = null;
private int port = 0;
private String userid = null;
private String passwd = null;
//SMS
private Sms smsCurrent = null;
private Sms smsOldest = null;
private Sms smsFailed = null;
private QueueHandler qh;
private int protocolType;
private SMSProtocolHandler myProtocolHandler;
private SMSModule(){
//Create a queue
qh = new QueueHandler();
public static SMSModule getInstance(){
if(instance == null){
instance = new SMSModule();
return instance;
public void run (){
while(true){
//Check queue
if(!qh.empty()){
send();
public void setProtocol(int protocolType){
this.protocolType=protocolType;
public void connect(String ip,
int port,
String username,
String password)
throws Exception{
if(myProtocolHandler!=null)
throw new Exception("SMS Module already connected!");
switch(protocolType){
case MSIP_PROTOCOL:
myProtocolHandler=new MSIPProtocolHandler();
break;
// case SMPP_PROTOCOL:
// myProtocolHandler=new SMPPProtocolHandler();
// break;
default:
throw new Exception("Protocoltype "+protocolType+" unknown or not set.");
myProtocolHandler.connect(ip,port,username,password);
public void disconnect() throws Exception{
if(myProtocolHandler==null)
throw new Exception("SMS Module not connected!");
myProtocolHandler.disconnect();
public boolean isLoggedIn(){
if(myProtocolHandler==null)
return false;
return myProtocolHandler.isLoggedIn();
public void sendSMS(){
if(isLoggedIn()){
//We have connection to SMSC
//Get sms from queue
smsCurrent =(Sms)qh.get();
//Get originator, body and destination
String from = smsCurrent.getOriginator();
String message = smsCurrent.getBody();
String to = smsCurrent.getDestination();
//send SMS
myProtocolHandler.sendSMS(from, message,to);
debug("Waiting for response from SMSC");
try{
Thread.sleep(5000);
}catch(Exception e){}
if(myProtocolHandler.getMessageSent()){
debug("Message has been sent");
myProtocolHandler.setMessageSent(false);
}else{
debug("Message not successfully sent");
//Put message back in queue
qh.add(smsCurrent);
}else{
System.err.println("There is no connection");
public void setHost(String host){
this.host = host;
public void setPort(int port){
this.port = port;
public void setUserid(String userid){
this.userid = userid;
public void setPasswd(String passwd){
this.passwd = passwd;
private void send(){
try {
connect(host,port,userid,passwd);
try{
Thread.sleep(5000);
}catch(Exception e){}
sendSMS();
try{
Thread.sleep(5000);
}catch(Exception e){}
disconnect();
}catch (Exception e){
e.printStackTrace();
/* Debug support */
private static boolean debugOn = true;
private static void debug(String msg){
if(debugOn)
System.out.println("\nCoolFlix log: "+msg+"\n");
public class MSIPProtocolHandler implements SMSProtocolHandler{
private MSIPHelper myHelper;
private Socket connection;
private BufferedReader in = null;
private PrintWriter out = null;
private boolean hasLoggedIn=false;
private boolean messageSent=false;
private MSIPIncomingHandlerThread myIncomingHandlerThread;
public MSIPProtocolHandler(){
myHelper=new MSIPHelper();
* F���rs���ker koppla upp sig mot en SMS-server.
* @param ip address till SMS-servern
* @param port port p��� SMS-servern
* @param username anv���ndarnamn f���r inloggning
* @param password l���senord f���r inloggning
public synchronized void connect( String ip,
int port,
String username,
String password){
System.out.println("MSIPProtocolHandler;connect");
if(connection!=null){
try{connection.close();}catch(Exception e){
System.out.println("MSIPProtocolHandler;connect;closing old connection:"+e.toString());}
try{
connection=new Socket(ip,port);
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
out = new PrintWriter(connection.getOutputStream(), true);
if(myIncomingHandlerThread!=null&&myIncomingHandlerThread.isAlive())
myIncomingHandlerThread.destroy();
myIncomingHandlerThread=new MSIPIncomingHandlerThread(in,this);
myIncomingHandlerThread.start();
String logonMessage=myHelper.createLogonRequest(username,password);
out.println(logonMessage);
}catch(Exception e){
e.printStackTrace();
try{connection.close();
in.close();
out.close();
}catch(Exception f){}
connection=null;
in=null;
out=null;
* F���rs���ker st���nga ner uppkopplingen mot SMS-servern om den ���r uppkopplad.
public synchronized void disconnect(){
System.out.println("MSIPProtocolHandler;disconnect");
try{
if(connection!=null){
//skicka en LogoffReq innan vi st���nger ner (egentligen ska man
//inte st���nga socketen innan man f���tt en LogoffConf, men...
out.println(myHelper.createLogoffRequest());
try{Thread.sleep(2000);}catch(Exception e){}
connection.close();
in.close();
out.close();
myIncomingHandlerThread.destroy();
}catch(Exception e){
e.printStackTrace();
connection=null;
in=null;
out=null;
* Skickar en SMS-PDU till SMS-servern.
* @param originator avs���ndare eller 'header'
* @param body SMS-texten
* @param destination slut-telefonnummer
* @return boolean 'true' om det kunde skickas.
public boolean sendSMS(String originator, String body, String destination){
/* H���r f���r man skriva hantering f���r att skapa en SubmitReq-PDU med
r���tt parametrar och skicka den till SMS-servern*/
debug("MSIPProtocolHandler;sendSMS");
if(connection !=null){
try {
//Create buffers for in-& out-streams.
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
out = new PrintWriter(connection.getOutputStream(), true);
//Start listener for incoming messages
if(myIncomingHandlerThread!=null&&myIncomingHandlerThread.isAlive()){
myIncomingHandlerThread.destroy();
myIncomingHandlerThread=new MSIPIncomingHandlerThread(in,this);
myIncomingHandlerThread.start();
//Create String to send on out stream
String sendMessage=myHelper.createSubmitRequest(body, destination);
out.println(sendMessage);
}catch (Exception e){
System.err.println("Exception caught :"+e.getMessage());
e.printStackTrace();
return false;
return true;
}else{
//No connection
return false;
public void setMessageSent(boolean status){
debug("MSIPProtocolHandler:setMessageSent()");
messageSent=status;
public boolean getMessageSent(){
debug("MSIPProtocolHandler:getMessageSent()");
return messageSent;
public boolean isLoggedIn(){
return this.hasLoggedIn;
public void setLoggedIn(boolean login){
debug("MSIPProtocolHandler;setLoggedin("+login+")");
this.hasLoggedIn=login;
/* Debug support */
private static boolean debugOn = true;
private static void debug(String msg){
if(debugOn)
System.out.println("\nCoolFlix log: "+msg+"\n");
public class MSIPIncomingHandlerThread extends Thread{
private Socket mySocket;
private BufferedReader myReader;
private boolean destroyed=false;
private MSIPHelper myHelper;
MSIPProtocolHandler myHandler;
public MSIPIncomingHandlerThread(BufferedReader myReader,
MSIPProtocolHandler myHandler){
this.myReader=myReader;
this.myHandler=myHandler;
myHelper=new MSIPHelper();
public void destroy(){
destroyed=true;
public void run(){
System.out.println("MSIPIncomingHandlerThread starting...");
String temp;
while(!destroyed){
try{
while((temp=myReader.readLine())!=null&&temp.length()>0){
System.out.println("GOT: "+temp);
myHelper.decodeMessage(temp);
if(myHelper.getMessageType().equals(MSIPHelper.LOGON_CONFIRMED))
myHandler.setLoggedIn(true);
else if(myHelper.getMessageType().equals(MSIPHelper.LOGON_REJECTED))
myHandler.setLoggedIn(false);
else if(myHelper.getMessageType().equals(MSIPHelper.LOGOFF_CONFIRMED))
myHandler.setLoggedIn(false);
else if(myHelper.getMessageType().equals(MSIPHelper.SUBMIT_CONFIRMED))
myHandler.setMessageSent(true);
else if (myHelper.getMessageType().equals(MSIPHelper.SUBMIT_REJECTED))
myHandler.setMessageSent(false);
}catch(Exception e){
e.printStackTrace();
System.out.println("MSIPIncomingHandlerThread dying...");
********************************************************************** -
Getpeername: Socket operation on non-socket
when i am starting the in.ftpd service. i am getting the below error
in.ftpd[5418]: [ID 572618 daemon.error] getpeername: Socket operation on non-socket.
Thanks in advance.I had the same problem with VMware. I also tried to connect with the VMware remote console, but got a similar error. In both cases it seems that it can not connect to the server for some very strange reasons.
I gave it another try with VMware player. The latest available version 3.1.0 and the previous version 3.0.1. Both versions did not start. The version 3.1.0 did not install a init script and 3.0.1 failed to start. In the end I gave up searching for errors.
Now I'm using VirtualBox and I am quite impressed of it's speed and stability. As long as you need a desktop virtualisation virtualbox will be probably all you need. I found it easier than vmware server. Sadly I was unable to try vmware player. So I can not compare the speed, but it is definetly faster than vmware servers remote console. But on the other hand the remote console of vmware server was developed for other purposes. It's not intended to be used as a desktop solution like vmware player.
If you need a full vmware server replacement then maybe xen would be a good try. Did not use it though, yet. -
Apple TV Model - A1378 SN-DC*******DR5 When new - numerous intermittent cut outs, then stopped working altogether. Reloaded SW, then experience total failure after 3-5 mins of operation. Reloaded SW again, now no operation at all. What happened?
<Edited By Host> -
A socket operation was attempted to an unreachable host
hi
while iam connecting from sftp client software to sap sftp server to upload the databade to sap.business one support and after entering the host ip adress,port no,suer name and password iam getting
"A socket operation was attempted to an unreachable host"
this error
can anyone know pls help me out and explain briefly
thanks in advance
janakihi,
Check this link
http://www.4-asp.net/forums/ShowPost.aspx?PostID=20
Jeyakanthan -
I've retrieved a download application in zip file format. During download, a message appears that states decompression failed. When I try to open the file, I get a message that the operation is not permitted. How do I correct this situation?
Make sure the place you are downloading the zip file isn't using a password protected zip file.
What operating system are you using?
Have you installed any decompresison software, or are you using the system built-in software?
Where are you downloading the application from?
Is your data backed up?
Are you using any firewall software or system optimization software, or any browser addon software? -
Operation on production order - what is the object (BOR) to manage it ?
Hello,
I have to call a workflow when an operation on production order is confirmed, or partially confirmed, or deleted.
What is the business object to use to manage it ??
Tks,
Roberto.Hello Uma,
yes, right...
yesterday, I was not able to see the trace when I deleting a production order becuase the object BUS2005 was not
active on customizing:
after I found it
No business object triggered for production order creation
end now is showed...
SO, we have to use BSVW ... and so the consequences is : How to know what is the object BOR to activate !??!?!
tks -
Non-blocking sockets operation, block/pausing for milli-seconds at a time.
The stack trace is always as follows. This operation can block for 1.0 to 2.1 ms approx once every 3 minutes, sometimes a second apart or not at all for 8 minutes. Have Java 6 update 18 on Centos 5.3. The server is lightly loaded.
at sun.nio.ch.NativeThread.current(Native Method)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:182)Looking at what this function does, its not clear why it should block/pause or how to fix it.
Any suggestions welcome.I would try running with hotspot disabled
in case something is optimized away
and you are actually blocked on some lock
and it only looks like you are blocked on NativeTread.current(). -
CAN'T DOWNLOAD READER AN ERROR WINDOW POPS UP "OPERATING SYSTEM ERROR! (16299.103.516-73272312.80004005.FFFFFFFF.00000000) WHAT DOES THIS MEAN. HELP THIS DAMSEL IN DISTRESS
I am trying to download Adobe Reader X (10.0.1) so I can not download any PDF's. I am downloading from http://get.adobe.com/reader/.
-
HAVE A MACBOOK PRO 2006 WITH NO OPERATING SYSTEM ON IT WHAT OSX DO I NEED FOR A FRESH INSTALL
I had to install new hhd and have no luck w/reinstall disc, so I believe I need retail disc does it matter what version of osx I use?
There were numerous MacBook Pros released in 2006. http://www.everymac.com/systems/apple/macbook_pro/index-macbookpro.html
The earliest came with OS 10.4.5 installed, but the max is OS 10.6.x. The last came with OS 10.4.8 installed, but the max is OS 10.7.x.
If you are able to get the original install discs from Apple, you should probably upgrade to OS 10.6.x or 10.7.x.
Cheers, Tom -
I've got a document , some 70 pages long that was made back in the late '80's with Pagemaker on an SEII mac. The docs are on 2 floppies, but I can't open them, because I can't find any application that can read the files. I've got other documents that go back to 1984, when I bought my first Mac, that I can't open, either. I'd like to be able to get these files into Pages and send them out to family once again. Any recommendations?
Thanks.No other application can open PageMaker files, only PageMaker. You'd need a copy of PageMaker (and license) and a Mac of ancient vintage, one with a floppy drive. The ancient Mac is needed not just to read the floppied but to run PageMaker which won't run on modern Macs.
Frankly, if you have a paper copy, scan it and start from that! -
I have ran mcafee anti-virus which has not found any viruses. Hope someone can help. Thanks
Disable your firewall and your antivirus and try again, after successfully install, enable it again.
thank you -
Problem with socket and Threads
Hi,
I have coded a package that sends an sms via a gateway.
Here is what is happening:
* I create a singleton of my SMSModule.
* I create an sms object.
* I put the object in a Queue.
* I start a new Thread in my sms module that reads sms from queue.
* I connect to sms gateway.
* I send the sms.
* I disconnect from socket! This is where things go wrong and I get the following error (see below).
I have a zip file with the code so if you have time to take a look at it I would appreciate it.
Anyway all hints are appreciated!
//Mikael
GOT: !LogoffConf:
mSIP Kommando var: !LogoffConf
CoolFlix log: MSIPProtocolHandler;setLoggedin(false)
We got LogOffConf
Waiting ......for thread to die
java.net.SocketException: Socket operation on nonsocket: JVM_recv in
socket input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:116)
at
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)Off the top of my head, probably the garbage collector cleared your SMSModule coz all classes loaded through other classloaders will be unloaded when that classloader is unloaded.
mail in the code if you want me to look at it with greater detail. -
UCCX8.5 connectivity issue using C++ Based CIL
Dear,
I have a custom CTI created with C++ Based CIL. The DLL was working ok with UCC4.6 on port number 42027 but with UCCX8.5 I am getting socket error(
10038 ErroMsg: Socket operation on nonsocket.) while sending KeepAlive message/HeartBeat request. I had changed different ports including 42028 that was found in ICM8.5 Ports utilization guide but no success.
Can any one help me to find the solution. I am assuming that it is happening due to wrong port number.
And yes, my application is able to connect the socket on port number 42028 and the ports I found using netstat command after I successfully logged in using CAD Desktop Application.
Your early response will help me a lot.
Regards
Kashif SurhioHi Mukesh Devrani,
Thank you for posting.
Your question is more like SQL. I suggest that you can ask your question in SQL forum.
http://social.msdn.microsoft.com/Forums/en/category/sqlserver/
Best Regards,
Larcolais
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact [email protected]
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Maybe you are looking for
-
Copy AP Invoice to AP credit memo got a discount per line automatically
Dear All, Our customer is in SAP8.8 SQL2008 CA localization. When they copy AP Invoice to AP credit memo (service type), the 1st line always has a discount (no matter which GL I choose). No matter which user I user no matter which posting date I choo
-
Connecting 2560x1440 screen to a U410 over HDMI
Hi, Im a new owner of U410 IdeaPad. I bought this machine with the intention to hook it up to a WQHD (2560x1440) screen. The screen I intend to get has no limitation on being fed over HDMI with this resolution (supports 1.4 HDMI). What I have found
-
Filling in a shape made with lines
I am really new to illustrator and I need to know the answer to this question fast. If I made a weird shape with 5 different lines how would I fill it in? Nothing really happens when I select the lines and then select a color. Thank you for answering
-
How do you overcome problems using Photoshop Elements with Win 7 and Eyefinity display?
I have a 3 screen Eyefinity setup on a PC running 64bit Win 7 with 16gb RAM and an AMD Radeon 7950 graphics card and Phenom II x4 processor. I struggle to get a stable PSE10 to work on this setup. I bought a combined set of Photoshop and Premier Elem
-
Does modified mean changed and saved or could it be changed and unsaved?
Hi, Hope this finds you well. Does anyone know if you can tell if a particular file has been worked in even if you didn't save it. For example, if you go look at a file in the finder (on a mac) and look at get info, does "modified" mean it was change