SocketException (code = 10055)

Hi all,
Here i go again. We are doing some data sending from a java socket to a C socket. Now the java side is receiving data from a serial port. The data is in the order of 7920 bytes per min. Great everything works fine, till 139 thousand odd messages are send (each message i mean a byte array of 11 bytes). But after those number of messages the java side receives a socketexception and code was indicated 10055. I looked up for this code, and in MSDN could get this code to indicate a TCP buffer full
(WSAENOBUFS (10055)
No buffer space available.
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full).
and the c side hangs. The best part is till we kill (ctrl-c) the C side i cannot even browse. I found out that if we increase the sendbuffer size on java side and c side increases the recv buffer size it would work just fine. I did that and the buffer size now is at 128K on both ends and decreased the number of bytes to 3300. But now the same error occurs after 170 thousand messages. Can anyone tell me
1. Is sending small chunks of data a problem.
2. What is the mbuff concept. I read someplace that the buff size is nothing but the number of mbuff the receiver tcp stack maintains.
To worsen my problems i am suppossed to do this whole thing on WINDOWS 2000 machine.
By the way the socket connection is to send data from a Java process to a C Process running in the same system. Does this complicate the problem??
Any help would be great. and all the ppl who reply will be given heartfelt good wishes:). HELPPPP MEEE B4 i go mad
arvind

Actually its 7920 bytes period in a minite. and i have
been able to find out that on the c side we have
threads that read data from sockets. each thread after
reading has to wait for few mutex and max time for
these is 200 millisecs. SO at max there can be only 5
messages(5*11 bytes = 55 bytes)that can be read every
second and i was sending 12 messages(12*11 = 132
bytes) per second before. So i did the flow control on
the jave side and i have been able to avoid the tcp
buffer full problem. But i still do not like this as
the messages will come slow and the data that has to
be received 10 secs earlier is received 10 secs
later..... is there any other method for this.
So each packet contains 11 bytes?
You can definitely read more than 5 per second. Even if all else fails one way is to buffer more than one message at a time. So instead of pushing every message to the queue. Push it every 5th packet.
Given that I have written socket handlers in java that pulled slightly more than 2000 TCP packets every second I am certain that you can increase the speed. Since java doesn't have 'mutexes' I am guessing that you are referring to synchronization and I would expect a faster time than that. How did you time the lock acquisition and release?

Similar Messages

  • Crazy Exception blocked my RMI server

    Hi all one crazy exception is thrown when I try to start the server. Plz reply me the the possible cause and solution.
    thanks in advance
    The exception is :
    Error starting service
    java.rmi.server.ExportException: Listen failed on port: 0; nested exception is:
    java.net.SocketException: JVM_Bind (code=10055)

    You cant listen / bind on port 0. Try a different port number greater than 1024. That should work out.

  • J2EE 620 standalone server error

    Hello Guys,
    WE have J2EE 620 standalone engine and receiving following error frequently in console log of state controller.
    We have 2 server node & dispatcher & state controller.
    Element 1474245011 joined.    Fri Aug 11 11:20:49 BST 2006
    [ClusterManager]: The loopback socket is broken. Probably the network cable is disconnected. Exception is: java.net.SocketException: JVM_recv in socket input stream read (code=10055)
    [Framework -> criticalShutdown] The loopback socket is broken. Probably the network cable is disconnected.
    Is any thing wrong in Windows 2003 server or j2ee engine?
    Regards,
    Atul

    Hello Guys,
    WE have J2EE 620 standalone engine and receiving following error frequently in console log of state controller.
    We have 2 server node & dispatcher & state controller.
    Element 1474245011 joined.    Fri Aug 11 11:20:49 BST 2006
    [ClusterManager]: The loopback socket is broken. Probably the network cable is disconnected. Exception is: java.net.SocketException: JVM_recv in socket input stream read (code=10055)
    [Framework -> criticalShutdown] The loopback socket is broken. Probably the network cable is disconnected.
    Is any thing wrong in Windows 2003 server or j2ee engine?
    Regards,
    Atul

  • For help! It seems not be with OS now?:(

    ============
    I tried to run the sample application provided by the tutorial on MulticastSocket. I use the java2sdk.
    I get the following error message
    Exception in thread "main" java.net.SocketException: set socket option failed (code=10055)
    at java.net.PlainDatagramSocketImpl.join(Native Method)
    at java.net.MulticastSocket.joinGroup(Unknown Source)
    at MulticastClient.main(MulticastClient.java:11)
    =============
    Hi, I got the same error!!!!
    I can run the sample code from school PC, but get this error in my home PC!! BUT they got the same version of Windows ME! After I try to upgrade to Windows 2000, the same error got there!!! How to debug this? There is no soultion from MS$ site:( I just run it locally, one for server, one for client.
    Great thanks,
    BB

    Presumably your home PC is connected to a network.
    For what is is worth this is what that error code means
    WSAENOBUFS (10055) No buffer space available.
    Berkeley description: An operation on a socket or pipe was not performed because the system lacked sufficient buffer space or because a queue was full.
    WinSock description: Same as Berkeley. The WinSock implementation was unable to allocate additional memory to accommodate the function request.
    User suggestions: This error indicates a shortage of resources on your system. It can occur if you're trying to run too many applications (of any kind) simultaneously on your machine. If this tends to occur after running certain applications for a while, it might be a symptom of an application that doesn't return system resources (like memory) properly. It may also indicate you are not closing the applications properly. If it persists, exit Windows or reboot your machine to remedy the problem. You can monitor available memory with Program Manager's "Help/About..." command.

  • JDBC Connection pool recovery after DB server restart

    I am finding that Kodo is throwing the following exception after I restart
    my database server (mysql). I am doing the database server restart while my
    application server is idle, so it is not during a transaction.
    Communication link failure: java.net.SocketException [code=0;state=08S01]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    This is presumably due to the JDBC connection pooling. Is there a
    configuration setting that allows Kodo to detect such failures and reconnect
    to the database server without exposing this problem to the application
    code? For example, WebLogic Server's JDBC connection pool has a setting that
    enables testing a connection and recovering from such failures before
    allocating it from the pool.
    Ben

    This is presumably due to the JDBC connection pooling. Is there a
    configuration setting that allows Kodo to detect such failures and reconnect
    to the database server without exposing this problem to the application
    code?Not right now. You can log an enhancement request with our bug database:
    http://bugzilla.solarmetric.com/

  • Error in OCS provisioning webconsole for migrated LDIF user --- [ESDS error

    I migrated an LDAP user via LDIF file (source objectclass is inetOrgPerson) through OCS directory provisioning web console. It imported successfully with 0 errors and 0 warnings.
    However, When I view this user via the same console.. I get the following error in the provisioning status for email.
    [ESDS error code - 10004] Invalid Email Id
    I made sure that email address in the ldif file is ok and it show properly in the console after import.
    Any clues please...
    Many many thanks in advance.
    MAAS

    I've been making further experiments with creating user accounts in OID (OCS 10g) with the main aim of testing possibilities of bulk import of OID user accouns from OCS 9.0.4 to the OCS 10g testing environment on another machine via LDIF format.
    Another error that I keep getting after re-creating the user account in OID is:
    Some Rows in the tables are disabled.
    Mail - [ESDS error code - 10055] Email id already in use as an email user
    I can't keep this error from appearing even though I tried to apply the workaround recommended for the Bug 4469130 - UNABLE TO PROVISION TO EMAIL, AFTER
    RECREATING A USER, which is:
    1) remove the user information from the storage database:
    % oesucr filename -clean_user_mailstore_data
    The file specified in filename is a text file that contains user IDs of deleted Oracle Mail users, as follows:
    [email protected],[email protected],[email protected],...
    2.) recreate the user in the OiD and provision the services.
    I know this bug and the workaround is related to the other error (Mail - [ESDS error code - 10004] Invalid Email Id) but I haven't been able to find any clues to "ESDS error code - 10055" and as a result I can't re-provision Mail component for any user that has been re-created (e.g. created, deleted, created again).
    The problem is probably related to the fact that when I ran the oesucr command for the second (third, forth...) time I got this:
    [oracle@merkur ~]$ oesucr oi.mail -clean_user_mailstore_data
    users delete from mailstore list size=5
    user to delete mailstore [email protected]
    [email protected] has not been deleted. Cannot remove mail store data
    user to delete mailstore [email protected]
    [email protected] has not been deleted. Cannot remove mail store data
    user to delete mailstore [email protected]
    [email protected] has not been deleted. Cannot remove mail store data
    user to delete mailstore [email protected]
    [email protected] has not been deleted. Cannot remove mail store data
    user to delete mailstore [email protected]
    [email protected] has not been deleted. Cannot remove mail store data
    The "oesucr filename -clean_user_mailstore_data" seems to work properly only when issued for the first time.
    Any help highly appreciated. Thanks
    Zdenek

  • The application requester cannot establish the connection.(Address in use:

    Hello All,
    I am using AS/400 type 4 Driver to connect and i am getting this error for every 1 hr if i restart the server again it will run till 1 hr and this error will come so pls help me
    java.sql.SQLException: The application requester cannot establish the connection.(connect (code=10055))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at com.ibm.as400.access.JDError.throwSQLException(JDError.java(Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java(Inlined Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java(Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java(Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java(Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at java.sql.DriverManager.getConnection(DriverManager.java(Compiled Code))
    [6/10/03 11:39:37:109 GMT+05:30] 3bf0d9b9 SystemErr R      at java.sql.DriverManager.getConnection(DriverManager.java:194)

    I don't know much about connecting to an AS/400 but what it looks like is that you have a connection already established to the machine and are trying to connect another one on top of it. I would check to see if you have a process that is not properly closing its connection to that machine.

  • Please help me with the code!!

    Dear All, I am going to simulate a TCP via UDP , and I have been asked for creating some specific methods , also additional helper methods are allowed but I can't avoid implementing any of the functions described below.
    I have bold the functions which are ambiguous to me.
    [click here to see the detail assignment explanation|http://www.net.t-labs.tu-berlin.de/teaching/ws0809/PD_labcourse/PDF/u5en.pdf|click here to see the detail assignment explanation]
    If you see anything wrong please post , thanks.
    • rdt connect()
    This function sets all the parameters required for connecting to a server. Moreover, it opens a
    UDP socket.
    • rdt listen()
    This function is the server-side counterpart of rdt connect(). It opens a UDP socket for
    incoming connections and sets all the required parameters.
    • rdt send()
    This function takes an arbirary amount of data as input and writes it into a send buffer. It
    does not send anything to the network.
    • rdt recv()
    This function returns the whole receive buffer. It does not really read data from the network,
    but only from the receive buffer.
    • rdt select()
    This function does the whole work of moving data over the network. It behaves similar to the
    system call select(), i.e. it blocks until there is some data in the receive buffer. The received
    data can be subsequently read with rdt recv(). A flow diagram of the functionality of this
    function follows:
    – send all()
    This function sends all the data in the send buffer over the network to the receiver. If
    more than 500 bytes are present in the send buffer, more packets must be sent. The MSS
    (Maximum Segment Size) of an RDT packet is 534 bytes.
    *– select()*
    This is the well-known system call that waits until the receive buffer contains data.
    [ I don't know what to do with the buffer , and how to make it empty]
    – recv from()
    This is the well-known system all recv from() that reads data from the network.
    *– statemachine send()*
    This is a function that processes a newly received packet. In RDT 1.0 nothing is done here,
    becuase the sender does not expect any ACK packets from the receiver.
    – statemachine recv()
    This function processes incoming packets. In RDT 1.0 the header is removed and the
    payload copied to the receive buffer.
    – Payload
    rdt select() returns at this point if there’s any data in the receive buffer. If not, it starts
    from the beginning.
    [ where the data should be returned?]
    This is my code:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.DatagramPacket;
    import java.net.DatagramSocket;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.SocketException;
    public class Ex5 {
        DatagramSocket socket , client_socket;
        DatagramPacket rcv_pkt;
        DatagramPacket send_pkt;
        byte[] sendData;
        byte[] receivedData;
        InetAddress ipaddr;
        int client_port;
        public void rdt_connect(String host , int client_port) throws IOException{
                this.client_port = client_port;
                client_socket = new DatagramSocket();
                ipaddr = InetAddress.getByName(host);
        public void rdt_listen(int port) throws SocketException{
            //byte[] buffer = new byte[1024];
            socket = new DatagramSocket(port);
            //DatagramPacket packet = new DatagramPacket(buffer, buffer.length );
        public DatagramPacket rdt_send() throws IOException{
            sendData = new byte[534];
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String inString = in.readLine();
            sendData = inString.getBytes();
            DatagramPacket send_packet = new DatagramPacket(sendData,sendData.length, ipaddr,client_port );
            return send_packet;
        public DatagramPacket rdt_recv(byte[] receivedData) throws IOException{
            //byte[] receivedData = new byte[1024];
            DatagramPacket received_packet = new DatagramPacket(receivedData, receivedData.length );
            //socket.receive(received_packet);
            return received_packet;
        public byte[] rdt_select() throws IOException{
            rcv_pkt = new DatagramPacket(receivedData,receivedData.length);
            while(!receivedData.equals(null)){
                return receivedData;
            send_all();
            return null;
        public void send_all() throws IOException{
            rcv_pkt = this.rdt_send();
            client_socket.send(rcv_pkt);
        public DatagramPacket select(){
            DatagramPacket local_rcv_pkt = null;
            while(receivedData != null){
                //local_rcv_pkt = rcv_pkt;
            return local_rcv_pkt;
        public void recv_from() throws IOException{
            rcv_pkt = select();
            socket.receive(rcv_pkt);
        public void statemachine_send(){
        public void statemachine_recv() throws IOException{
            String data = new String(rcv_pkt.getData());
            receivedData = data.getBytes();
            rcv_pkt = this.rdt_recv(receivedData);
    }

    public class Ex5 {
    DatagramSocket socket , client_socket;Surely you're not expected to implement the client and the server in the same class?
    while(!receivedData.equals(null)){
    return receivedData;
    }This is just nonsense.
    public DatagramPacket select(){See java.nio.channels.Selector.
    while(receivedData != null){
    //local_rcv_pkt = rcv_pkt;
    }More nonsense.
    I suggest if you don't understand the assignment you advise those who gave it to you, and/or review whatever supporting information you were supplied or have been taught.

  • Error While running the JSP Code

    This is the error message:
    A java exception has occurred during the processing of this request.
    Error occurred in JSP element starting at line number 20
    javax.servlet.jsp.JspTagException: I/O Error: java.net.SocketException: Connection reset
         at desisoft.jsp.tagext.SendMail.doAfterBody(SendMail.java:213)
         at desisoft_jsp_SendMail_jsp1139292195218._jspService(desisoft_jsp_SendMail_jsp1139292195218.java:111)
         at desisoft.server.JspBaseClass.service(JspBaseClass.java:48)
    The JSP code:
    <%@ taglib prefix="blx" uri="/blx.tld" %>
    <HTML>
    <BODY>
    <%
    // Get username.
    String email = request.getParameter( "email" );
    %>
    <% if ( email == null || email.equals( "" )) { %>
    Please enter an email address.
    <% } else { %>
    <blx:email host="mail.xxx.com" from="[email protected]">
    <blx:emailTo><%= email %></blx:emailTo>
    Thank you for registering with us. You registered the
    following name: <%= request.getParameter( "username" ) %>
    Your registration was received at <%= new java.util.Date() %>
    Attached, please find a contents file.
    </blx:email>
    <!-- Also write out some HTML -->
    Thank you. A confirmation email has been sent to <%= email %>
    <% } %>
    </BODY>
    </HTML>

    This is the error message:
    A java exception has occurred during the processing of this request.
    Error occurred in JSP element starting at line number 20
    javax.servlet.jsp.JspTagException: I/O Error: java.net.SocketException: Connection reset
         at desisoft.jsp.tagext.SendMail.doAfterBody(SendMail.java:213)
         at desisoft_jsp_SendMail_jsp1139292195218._jspService(desisoft_jsp_SendMail_jsp1139292195218.java:111)
         at desisoft.server.JspBaseClass.service(JspBaseClass.java:48)
    The JSP code:
    <%@ taglib prefix="blx" uri="/blx.tld" %>
    <HTML>
    <BODY>
    <%
    // Get username.
    String email = request.getParameter( "email" );
    %>
    <% if ( email == null || email.equals( "" )) { %>
    Please enter an email address.
    <% } else { %>
    <blx:email host="mail.xxx.com" from="[email protected]">
    <blx:emailTo><%= email %></blx:emailTo>
    Thank you for registering with us. You registered the
    following name: <%= request.getParameter( "username" ) %>
    Your registration was received at <%= new java.util.Date() %>
    Attached, please find a contents file.
    </blx:email>
    <!-- Also write out some HTML -->
    Thank you. A confirmation email has been sent to <%= email %>
    <% } %>
    </BODY>
    </HTML>

  • How to display the source code for this friggin' file.

    Below is a rather lengthy bit of code that provides the behavior and attributes of a web server for OpenCyc. I need to know if I can enter some java to have the HTML source code displayed in a separate text file whenever this class returns some resulting webpage. If you have any ideas it will be greatly appreciated.
    -"Will code for foo."
    package org.opencyc.webserver;
    * Class WebServer is simple multithreaded HTTP server
    * with CGI limited to a Cyc connection on default port 3600.
    * <p>
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    import java.text.*;
    import org.opencyc.util.*;
    public class WebServer extends Thread {
         * Singleton WebServer instance.
        public static WebServer current;
         * Default HTTP port.
        protected static int DEFAULT_PORT = 80;
         * Default Cyc base port.
        protected static int DEFAULT_CYC_PORT = 3600;
         * Default directory to serve files from on non-Windows OS.
        protected static String DEFAULT_DIR = "/";
         * Default directory to serve files from on Windows.
        //protected static String DEFAULT_WIN_DIR = "C:\\";
        protected static String DEFAULT_WIN_DIR = "k:\\opencyc\\run\\httpd\\htdocs";
         * File cache capacity.
        protected static final int CACHE_CAPACITY = 100;
         * File cache to improve file serving performance.
        protected static Hashtable fileCache = new Hashtable(CACHE_CAPACITY);
         * Number of files served from this web server.
        protected static long nbrFilesServed = 0;
         * Number of files served from this web server that were found in the cache.
        protected static long nbrCacheHits = 0;
         * Server socket for accepting connections.
        protected ServerSocket server;
         * Directories to serve files from.
        protected ArrayList dirs;
         * Map from String (jar root) to JarFile[] (jar class path).
        protected HashMap map;
         * Webserver HTTP port.
        protected int port;
         * Cyc HTML host.
        protected String cycHost = "localhost";
         * Cyc HTML port.
        protected int cycPort;
         * Expand jar tress.
        protected boolean trees;
         * Requests flag.
        protected boolean traceRequests;
         * Constructs a WebServer object.
         * @param port the port to use
         * @param directories the directory to serve files from
         * @param trees true if files within jar files should be served up
         * @param traceRequests true if client's request text should be logged.
         * @exception IOException if the listening socket cannot be opened, or problem opening jar files.
        public WebServer() throws IOException {
            getProperties();
            server = new ServerSocket(port);
            processDirectories();
         * Class Task processes a single HTTP request.
        protected class Task extends Thread {
             * Socket for the incoming request.
            protected Socket sock;
             * Client socket to the Cyc KB HTML server.
            protected Socket cycHtmlSocket;
             * Output tcp stream.
            protected DataOutputStream out;
             * Contains the file request path for a not-found error message.
            protected String notFoundPath;
             * Contains the first line of a request message.
            protected String methodLine;
             * Contains the body of a POST method.
            protected String bodyLine;
             * Constructs a Task object.
             * @param sock the socket assigned for this request.
            public Task(Socket sock) {
                this.sock = sock;
             * Processes the HTTP request.
            public void run() {
                if (traceRequests)
                    Log.current.println("connection accepted from " + sock.getInetAddress());
                notFoundPath = "";
                try {
                    out = new DataOutputStream(sock.getOutputStream());
                    try {
                        getBytes();
                    catch (Exception e) {
                        Log.current.println("file not found: " + notFoundPath);
                        try {
                            out.writeBytes("HTTP/1.1 404 Not Found\r\n");
                            out.writeBytes("Server: Cyc WebServer\r\n");
                            out.writeBytes("Connection: close\r\n");
                            out.writeBytes("Content-Type: text/html\r\n\r\n");
                            out.writeBytes("<HTML><HEAD>\n");
                            out.writeBytes("<TITLE>404 Not Found</TITLE>\n");
                            out.writeBytes("</HEAD><BODY>\n");
                            out.writeBytes("<H1>404 - Not Found</H1>\n");
                            out.writeBytes("</BODY></HTML>");
                            out.flush();
                        catch (SocketException se) {
                catch (Exception e) {
                    Log.current.printStackTrace(e);
                finally {
                    try {
                        sock.close();
                    catch (IOException e) {
             * Reads the HTTP request and obtains the response.
             * @exception IOException when HTTP request has an invalid format.
            private void getBytes() throws IOException {
                // Below logic is complex because web browsers do not close the
                // socket after sending the request, so must parse message to find
                // the end.
                BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                ArrayList inBytes = new ArrayList(200);
                int ch = 0;
                boolean postMethod;
                methodLine = in.readLine();
                //if (traceRequests)
                //    Log.current.println("methodLine=" + methodLine);
                bodyLine = "";
                if (methodLine.startsWith("POST /"))
                    postMethod = true;
                else
                    postMethod = false;
                //if (traceRequests)
                //    Log.current.println("postMethod=" + postMethod);
                int ch1 = -1;
                int ch2 = -1;
                int ch3 = -1;
                int ch4 = -1;
                // Read the HTTP request headers.
                while (true) {
                    ch = in.read();
                    inBytes.add(new Integer(ch));
                    ch1 = ch2;
                    ch2 = ch3;
                    ch3 = ch4;
                    ch4 = ch;
                    if (ch1 == '\r' && ch2 == '\n' && ch3 == '\r' && ch4 == '\n')
                        break;
                    if ((! postMethod) &&
                        (! in.ready()) &&
                        ch1 == -1 &&
                        ch2 == -1 &&
                        ch3 == '\r' &&
                        ch4 == '\n') {
                        inBytes.add(new Integer('\r'));
                        inBytes.add(new Integer('\n'));
                        break;
                byte[] byteArray = new byte[inBytes.size()];
                for (int i = 0; i < inBytes.size(); i++) {
                    Integer ich = (Integer) inBytes.get(i);
                    byteArray[i] = ich.byteValue();
                String headers = new String(byteArray);
                if (postMethod) {
                    String lcHeaders = headers.toLowerCase();
                    int i = lcHeaders.indexOf("content-length: ");
                    String contentLength = lcHeaders.substring(i + 16);
                    int j = contentLength.indexOf("\r\n");
                    contentLength = contentLength.substring(0, j);
                    int bodyLen = (new Integer(contentLength)).intValue();
                    for (int k = 0; k < bodyLen; k++) {
                        bodyLine = bodyLine + (new Character((char) in.read())).toString();
                String line = methodLine + "\r\n" + headers + bodyLine;
                if (traceRequests)
                    Log.current.println(line);
                if (postMethod)
                    processHttpPost();
                else
                    if (line.startsWith("GET /"))
                        processHttpGet(line.substring(4));
                    else {
                        Log.current.println("Invalid request = " + line);
                        throw new IOException();
             * Processes an HTTP GET method.
             * @param httpGetPath the path of the file to get.
             * @exception IOException if the file is not found.
            private void processHttpGet(String httpGetPath) throws IOException {
                int i = httpGetPath.indexOf(' ');
                if (i > 0)
                    httpGetPath = httpGetPath.substring(0, i);
                Log.current.println(methodLine + " from " + sock.getInetAddress().getHostName());
                i = httpGetPath.indexOf("cg?");
                if (i > 0) {
                    cycHtmlRequest(httpGetPath.substring(i + 3));
                    return;
                notFoundPath = httpGetPath;
                i = httpGetPath.indexOf('/');
                if (i < 0 || map == null) {
                    if (map == null || httpGetPath.endsWith(".jar")) {
                        for (int j = 0; j < dirs.size(); j++) {
                            String dir = (String) dirs.get(j);
                            String nativePath = dir + httpGetPath;
                            nativePath = nativePath.replace('/', File.separatorChar);
                            if (fileCache.containsKey(nativePath)) {
                                writeDataBytes((byte[]) fileCache.get(nativePath));
                                Log.current.println("...cached");
                                nbrCacheHits++;
                                nbrFilesServed++;
                                return;
                            try {
                                File f = new File(nativePath);
                                byte[] fileBytes = getBytes(new FileInputStream(f), f.length());
                                writeDataBytes(fileBytes);
                                if (fileCache.size() >= CACHE_CAPACITY)
                                    fileCache.clear();
                                fileCache.put(nativePath, fileBytes);
                                Log.current.println("...from " + nativePath);
                                nbrFilesServed++;
                                return;
                            catch (IOException e) {
                    throw new IOException();
                String jar = httpGetPath.substring(0, i);
                httpGetPath = httpGetPath.substring(i + 1);
                JarFile[] jfs = (JarFile[]) map.get(jar);
                if (jfs == null)
                    throw new IOException();
                for (i = 0; i < jfs.length; i++) {
                    JarEntry je = jfs.getJarEntry(httpGetPath);
    if (je == null)
    continue;
    writeDataBytes(getBytes(jfs[i].getInputStream(je), je.getSize()));
    nbrFilesServed++;
    return;
    throw new IOException();
    * Processes an HTTP POST method.
    * @exception IOException if the file is not found.
    private void processHttpPost() throws IOException {
    Log.current.println("POST " + bodyLine + " from " + sock.getInetAddress().getHostName());
    cycHtmlRequest(bodyLine);
    * Reads the specified number of bytes and always close the stream.
    * @param in the file to be read for subsequent downloading.
    * @param length the number of bytes to read from the file.
    * @return An array of bytes from the file.
    * @exception IOException if an error occurs when processing the file.
    private byte[] getBytes(InputStream in, long length) throws IOException {
    DataInputStream din = new DataInputStream(in);
    byte[] bytes = new byte[ (int) length];
    try {
    din.readFully(bytes);
    finally {
    din.close();
    return bytes;
    * Sends the HTML request to Cyc.
    * @param cycPath the portion of the URL which is given to the Cyc HTML server.
    private void cycHtmlRequest(String cycPath) {
    String request = sock.getInetAddress().getHostName() + "&" + cycPath + "#";
    System.out.println("request=" + request);
    ArrayList bytes = new ArrayList(10000);
    try {
    cycHtmlSocket = new Socket(cycHost, cycPort);
    System.out.println("cycHost=" + cycHost + " cycPort=" + cycPort);
    BufferedReader cycIn = new BufferedReader(new InputStreamReader(cycHtmlSocket.getInputStream()));
    PrintWriter cycOut = new PrintWriter(cycHtmlSocket.getOutputStream(), true);
    cycOut.println(request);
    cycOut.flush();
    int ch = 0;
    while (ch >= 0) {
    ch = cycIn.read();
    bytes.add(new Integer(ch));
    catch (Exception e) {
    Log.current.printStackTrace(e);
    byte[] byteArray = new byte[bytes.size()];
    for (int i = 0; i < bytes.size() - 1; i++) {
    Integer ich = (Integer) bytes.get(i);
    byteArray[i] = ich.byteValue();
    try {
    writeTextBytes(byteArray);
    catch (Exception e) {
    Log.current.println(e.getMessage());
    * Responds to the HTTP client with data content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeDataBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    String prefix = (new String(bytes)).toLowerCase();
    if (prefix.indexOf("<html>") > -1)
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    else
    out.writeBytes("Content-Type: application/java\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Respond to the HTTP client with text content from the requested URL.
    * @param bytes the array of bytes from the URL.
    * @exception IOException if there is an error writing to the HTTP client.
    public void writeTextBytes(byte[] bytes) throws IOException {
    out.writeBytes("HTTP/1.1 200 OK\r\n");
    out.writeBytes("Server: Cyc WebServer\r\n");
    out.writeBytes("Connection: close\r\n");
    out.writeBytes("Content-Length: " + bytes.length + "\r\n");
    out.writeBytes("Content-Type: text/html\r\n\r\n");
    out.write(bytes);
    out.flush();
    * Gets properties governing the web server's behavior.
    private void getProperties() {
    port = DEFAULT_PORT;
    String portProperty = System.getProperty("org.opencyc.webserver.port", "");
    if (! portProperty.equalsIgnoreCase(""))
    port = (new Integer(portProperty)).intValue();
    Log.current.println("Listening on port " + port);
    cycPort = DEFAULT_CYC_PORT;
    String cycPortProperty = System.getProperty("org.opencyc.webserver.cycPort", "");
    if (! cycPortProperty.equalsIgnoreCase(""))
    cycPort = (new Integer(cycPortProperty)).intValue();
    Log.current.println("Cyc connections directed to port " + cycPort);
    String dirsProperty = System.getProperty("org.opencyc.webserver.dirs", "");
    dirs = new ArrayList(3);
    StringTokenizer st = new StringTokenizer(dirsProperty, ";", false);
    while (st.hasMoreTokens()) {
    String dir = st.nextToken();
    dirs.add(dir);
    trees = false;
    String treesProperty = System.getProperty("org.opencyc.webserver.trees", "");
    if (! treesProperty.equalsIgnoreCase(""))
    trees = true;
    traceRequests = false;
    String traceRequestsProperty = System.getProperty("org.opencyc.webserver.traceRequests", "");
    if (! traceRequestsProperty.equalsIgnoreCase("")) {
    traceRequests = true;
    Log.current.println("tracing requests");
    * Adds transitive Class-Path jars to jfs.
    * @param jar the jar file
    * @param jfs the list of jar files to serve.
    * @param dir the jar file directory.
    * @exception IOException if an I/O error has occurred with the jar file.
    private void addJar(String jar, ArrayList jfs, String dir) throws IOException {
    Log.current.println("Serving jar files from: " + dir + jar);
    JarFile jf = new JarFile(dir + jar);
    jfs.add(jf);
    Manifest man = jf.getManifest();
    if (man == null)
    return;
    Attributes attrs = man.getMainAttributes();
    if (attrs == null)
    return;
    String val = attrs.getValue(Attributes.Name.CLASS_PATH);
    if (val == null)
    return;
    dir = dir + jar.substring(0, jar.lastIndexOf(File.separatorChar) + 1);
    StringTokenizer st = new StringTokenizer(val);
    while (st.hasMoreTokens()) {
    addJar(st.nextToken().replace('/', File.separatorChar), jfs, dir);
    * Administrative accessor method that obtains list of directories from which files are served.
    public ArrayList getDirs() {
    return dirs;
    * Administrative method that updates the list of directories from which files are served.
    public synchronized void setDirs(ArrayList dirs) throws IOException {
    this.dirs = dirs;
    fileCache.clear();
    processDirectories();
    * Administrative accessor method that obtains number of files served.
    * @return The number of files served.
    public long getNbrFilesServed() {
    return nbrFilesServed;
    * Administrative accessor method that obtains number of files served from cache.
    * @return The number of files served from the cache.
    public long getNbrCacheHits() {
    return nbrCacheHits;
    * Administrative method that clears the file cache.
    public synchronized void clearFileCache() {
    Log.current.println("Clearing file cache");
    fileCache.clear();
    nbrFilesServed = 0;
    nbrCacheHits = 0;
    * Processes the directories from which files are served, expanding jar trees if
    * directed.
    * @exception IOException if problem occurs while processing the jar files.
    private void processDirectories() throws IOException {
    if (dirs.size() == 0)
    if (File.separatorChar == '\\')
    dirs.add(DEFAULT_WIN_DIR);
    else
    dirs.add(DEFAULT_DIR);
    Iterator directories = dirs.iterator();
    while (directories.hasNext())
    Log.current.println("Serving from " + directories.next());
    if (trees) {
    map = new HashMap();
    for (int j = 0; j < dirs.size(); j++) {
    String dir = (String) dirs.get(j);
    String[] files = new File(dir).list();
    for (int i = 0; i < files.length; i++) {
    String jar = files[i];
    if (!jar.endsWith(".jar"))
    continue;
    ArrayList jfs = new ArrayList(1);
    addJar(jar, jfs, dir);
    map.put(jar.substring(0, jar.length() - 4), jfs.toArray(new JarFile[jfs.size()]));
    * Provides the command line interface for creating an HTTP server.
    * The properties are:
    * <pre>
    * org.opencyc.webserver.port=<HTTP listening port>
    * </pre>
    * which defaults to 80.
    * <pre>
    * org.opencyc.webserver.cycPort=<Cyc connection port>
    * </pre>
    * which defaults to 3600.
    * <pre>
    * org.opencyc.webserver.dirs=<path>;<path> ... ;<path>
    * </pre>
    * with the argument enclosed in quotes if any path contains an
    * embedded space.
    * The default directory on Windows is C:
    * and the default on other systems is / the default
    * can be overridden with this property. By default, all files
    * under this directory (including all subdirectories) are served
    * up via HTTP. If the pathname of a file is <var>path</var> relative
    * to the top-level directory, then the file can be downloaded using
    * the URL
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>path</var>
    * </pre>
    * Caching of file contents is performed.
    * <pre>
    * org.opencyc.util.log=all
    * </pre>
    * If the all value is given, then all attempts to download files
    * are output.
    * <pre>
    * org.opencyc.webserver.traceRequests
    * </pre>
    * If this property has any value, then the client HTTP requests are
    * output.<p>
    * <pre>
    * org.opencyc.webserver.trees
    * </pre>
    * This property can be used to serve up individual files stored
    * within jar files in addition to the files that are served up by
    * default. If the property has any value, the server finds all jar files
    * in the top-level directory (not in subdirectories). For each
    * jar file, if the name of the jar file is <var>name</var>.jar, then any
    * individual file named <var>file</var> within that jar file (or within
    * the jar or zip files referenced transitively in the Class-Path manifest
    * attribute, can be downloaded using a URL of the form:
    * <pre>
    * http://<var>host</var>:<var>port</var>/<var>name</var>/<var>file</var>
    * </pre>
    * When this property has any value, an open file descriptor and cached
    * information are held for each jar file, for the life of the process.
    * @param args an unused array of command line arguments.
    public static void main(String[] args) {
    Log.makeLog();
    System.out.println("OpenCyc Web Server");
    try {
    // Launch thread to accept HTTP connections.
    current = new WebServer();
    current.start();
    catch (IOException e) {
    e.printStackTrace();
    * Just keep looping, spawning a new thread for each incoming request.
    public void run() {
    try {
    while (true) {
    // Launch thread to process one HTTP request.
    new Task(server.accept()).start();
    catch (IOException e) {
    e.printStackTrace();

    JLundan,
    I want to thank you for responding to the thread I started on the forum at java.sun.com. Your solution to my problem of needing to print the code of the html pages that the file I included generates was just what I was looking for. However, I have some further questions to ask, if you don't mind. To clarify my task I should say that your rephrasing of the problem is accurate: "You wan't to display the contents of the HTML file that the web server produces in response of client's request?"
    Yes, this is what I need to do, but also it needs to display the source code of that html file that the server produces in response to the client's request. Also, in this case, I am the client requesting that the server return some html file, and I'm not sure where the server is. But the webserver.java file that I shared on the forum is on my local machine. I was wondering if I could modify this webserver.java file at my home so that any html file the server returns to me would automatically display the source code. This is a school project of mine and I am stuck on this one thing here.
    Further, where would I put the "foo.html" file so it can be written to?
    FileOuputStream fos = new FileOutputStream("foo.html");
    fos.write(bytes);
    fos.close();
    Thanks so much for your help. I look forward to your response, at your convenience.
    Regards

  • SocketException during reads - JVM_recv in socket input stream read

    I am getting a SocketException when a Java applet talks to our
    WebLogic 7.0 server. The catch is that it only occurs at one site
    (that has very high T1 utilization, although latency is only ~60 ms)
    Our setup is such that the calls hit an Alteon load balancer, which
    then sends the request out to one of 4 IIS clustered servers, where it
    then is sent to one of 2 WL clustered servers. I figured latency
    would be the cause, but on IIS and on WL, the timeouts are set to
    several hundred seconds, so I am not quite seeing where the connection
    is being reset. To be honest, I really don't know if it is WL that is
    killing the connection, as nothing abnormal shows up in the WL log. I
    have seen similar problems in this group, though, although the stack
    traces never follow the same path mine does. I do have the following
    call stack from the Java plug-in console, though. Any ideas would be
    greatly appreciated.
    java.net.SocketException: Connection reset by peer: JVM_recv in socket
    input stream read
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(Unknown Source)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read1(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
         at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
    Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
         at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
         at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Also, here is my code, although I can't see anything on the client
    side that seems off:
    public Object sendRequest( Object request, URL receiver ) throws
    Exception{
    Object response = null;
    URLConnection con = null;
    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    try {
    con = receiver.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    con.setAllowUserInteraction(false);
    out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(request);
    out.flush();
    out.close();
    in = new ObjectInputStream(con.getInputStream());
    response = in.readObject();
    in.close();
    } catch (ClassCastException e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    } catch (Exception e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    throw e;
    return response;

    There is a known bug on earlier 1.3.1 releases with sockets on Windows 2k
    and XP. I don't remember all the details.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic
    "Keith Patrick" <[email protected]> wrote in message
    news:[email protected]...
    I'm getting the exception on the client, which is an XP machine, while
    the server is Win2K. I can't recall which, but either the applet or
    the server runs 1.3x while the other runs 1.4. I discounted that
    factor, though, as the problem only occurs on one site, which on all
    others it works fine.
    "Cameron Purdy" <[email protected]> wrote in message
    news:<[email protected]>...
    Exception is in the applet or on the server?
    Would one of those by any chance be running on W2K with JDK 131_01 orolder?
    >>
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic
    "Keith Patrick" <[email protected]> wrote in message
    news:[email protected]...
    I am getting a SocketException when a Java applet talks to our
    WebLogic 7.0 server. The catch is that it only occurs at one site
    (that has very high T1 utilization, although latency is only ~60 ms)
    Our setup is such that the calls hit an Alteon load balancer, which
    then sends the request out to one of 4 IIS clustered servers, where it
    then is sent to one of 2 WL clustered servers. I figured latency
    would be the cause, but on IIS and on WL, the timeouts are set to
    several hundred seconds, so I am not quite seeing where the connection
    is being reset. To be honest, I really don't know if it is WL that is
    killing the connection, as nothing abnormal shows up in the WL log. I
    have seen similar problems in this group, though, although the stack
    traces never follow the same path mine does. I do have the following
    call stack from the Java plug-in console, though. Any ideas would be
    greatly appreciated.
    java.net.SocketException: Connection reset by peer: JVM_recv in socket
    input stream read
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at
    sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
    Source)
    atsun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
    Source)
    atsun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
    Source)
    at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
    at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Also, here is my code, although I can't see anything on the client
    side that seems off:
    public Object sendRequest( Object request, URL receiver ) throws
    Exception{
    Object response = null;
    URLConnection con = null;
    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    try {
    con = receiver.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    con.setAllowUserInteraction(false);
    out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(request);
    out.flush();
    out.close();
    in = new ObjectInputStream(con.getInputStream());
    response = in.readObject();
    in.close();
    } catch (ClassCastException e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    } catch (Exception e) {
    if( out != null ){
    out.close();
    if( in != null ){
    in.close();
    throw e;
    return response;

  • JCOM on WLS 8.1 - SocketException: Socket closed

    After creating my application and accessing it - if I don't use it for a while
    I get the following exception when I access it. Other than creating a timer to
    ping it every 10 seconds or so - is there some way to keep the socket open?
    - Mike Reiche
    java.net.SocketException: Socket closed
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:124)
    at com.linar.jintegra.RpcConnectionHandler.send(RpcConnectionHandler.java:272)
    at com.linar.jintegra.Rpc.invoke(Rpc.java:239)
    at com.linar.jintegra.RemObjectExporter.invoke(RemObjectExporter.java:346)
    at com.linar.jintegra.StdObjRef.invoke(StdObjRef.java:57)
    at com.linar.jintegra.Dispatch.vtblInvoke(Dispatch.java:763)
    at excel._ApplicationProxy.getDefaultFilePath(_ApplicationProxy.java:1938)
    at excel.Application.getDefaultFilePath(Application.java:2237)

    Has anyone gotten an answer on this error? I also get a Socket Closed IOException
    after a couple of minutes of not communicating to a remote DCOM application.
    I also have to restart Weblogic to get it to communicate again. Works great as
    long as I make a request every 10 or 20 seconds.
    Rick Holland
    >
    I am having this exact same problem. I have a support case opened with
    BEA about
    it, and will let you know if I come up with a solution...
    In my case, however, I am gonna have a very hard time sending BEA a repeatable
    testcase that demonstrates this problem, as I access a DCOM app that
    I cant redistribute.
    Would your code be something that you can share with BEA? If so, that
    would be
    of tremendous help.
    "Mike Reiche" <mreiche@no_spam.com> wrote:
    After creating my application and accessing it - if I don't use it for
    a while
    I get the following exception when I access it. Other than creating
    a timer to
    ping it every 10 seconds or so - is there some way to keep the socket
    open?
    - Mike Reiche
    java.net.SocketException: Socket closed
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:124)
    at com.linar.jintegra.RpcConnectionHandler.send(RpcConnectionHandler.java:272)
    at com.linar.jintegra.Rpc.invoke(Rpc.java:239)
    at com.linar.jintegra.RemObjectExporter.invoke(RemObjectExporter.java:346)
    at com.linar.jintegra.StdObjRef.invoke(StdObjRef.java:57)
    at com.linar.jintegra.Dispatch.vtblInvoke(Dispatch.java:763)
    at excel._ApplicationProxy.getDefaultFilePath(_ApplicationProxy.java:1938)
    at excel.Application.getDefaultFilePath(Application.java:2237)

  • Multicast Sender and Receiver code problem

    Hi
    I am developing a multicast chat program. I am using codes from a well known book "Java Network Programming". I have run both programs 'MulticastSniffer' and 'MulticastSender'
    MulticastSniffer runs OK but MulticastSender gives me the error below:
    java.lang.NumberFormatException: null
    Usage: java MulticastSender multicast_address port ttl
    I cant figure out the error. Could some one please help me here to find the error. I have put both programs below: Thanks
    Here is the code for MulticastSniffer.java
    import java.net.*;
    import java.io.*;
    public class MulticastSniffer {
    public static void main(String[] args) {
    InetAddress group = null;
    int port = 0;
    // read the address from the command line
    try {
    group = InetAddress.getByName("235.0.0.1");
    port = Integer.parseInt("8192");
    } // end try
    catch (Exception e) {
    // ArrayIndexOutOfBoundsException, NumberFormatException,
    // or UnknownHostException
    System.err.println(
    "Usage: java MulticastSniffer multicast_address port");
    System.exit(1);
    MulticastSocket ms = null;
    try {
    ms = new MulticastSocket(port);
    ms.joinGroup(group);
    byte[] buffer = new byte[8192];
    while (true) {
    DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
    ms.receive(dp);
    String s = new String(dp.getData());
    System.out.println(s);
    catch (IOException e) {
    System.err.println(e);
    finally {
    if (ms != null) {
    try {
    ms.leaveGroup(group);
    ms.close();
    catch (IOException e) {}
    Here is the code for MulticastSender
    import java.net.*;
    import java.io.*;
    public class MulticastSender {
    public static void main(String[] args) {
    InetAddress ia = null;
    int port = 4445;
    byte ttl = (byte) 1;
    // read the address from the command line
    try {
    ia = InetAddress.getByName("235.0.0.1");
    port = Integer.parseInt(null,4445);
    if (args.length > 2) ttl = (byte) Integer.parseInt("8192");
    catch (Exception e) {
    System.err.println(e);
    System.err.println(
    "Usage: java MulticastSender multicast_address port ttl");
    System.exit(1);
    byte[] data = "Here's some multicast data\r\n".getBytes();
    DatagramPacket dp = new DatagramPacket(data, data.length, ia, port);
    try {
    MulticastSocket ms = new MulticastSocket();
    for (int i = 1; i < 10; i++) {
    ms.send(dp, ttl);
    ms.close();
    catch (SocketException se) {
    System.err.println(se);
    catch (IOException ie) {
    System.err.println(ie);
    I will appreciate your help

    Hi kdajani thanks for reply
    It doesnt give any line number or doesnt tell where the error is.
    after i run the program it gives error below. if you run the program you will see what happens.
    java.lang.NumberFormatException: null
    Usage: java MulticastSender multicast_address port ttl
    And
    according to the reply from sabre150 , I have tried using
    port = Integer.parseInt(null,"4445");
    using above code gives the error below
    MulticastSender.java:18: cannot find symbol
    symbol : method parseInt(<nulltype>,java.lang.String)
    location: class java.lang.Integer
    port = Integer.parseInt(null,"4445");
    and
    port = 4445;
    using this does not execute at all
    They dont work either.
    Thanks you all

  • SocketException error.

    From time to time one of our JSP pages is throwing this error
              Wed Aug 30 13:56:45 GMT 2000:<E> <ServletContext-General> exception raised
              on '/
              Login.jsp'
              java.net.SocketException: Connection reset by peer: socket write error
              at java.net.SocketOutputStream.socketWrite(Native Method)
              at java.net.SocketOutputStream.write(SocketOutputStream.java,
              Compiled C
              ode)
              at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java,
              Com
              piled Code)
              It doesn't do it all the time and it doesn't seem to cause a probelm or have
              any effect on the output on our clients. Can someone tell me what this
              error is and what I can do about it?
              

    Typically, this means that the browser connection has gone away. This could
              happen if the user browses to another page or closes the browser before the
              server is done sending the current page.
              It's harmless.
              anders
              "Mike Salway" <[email protected]> wrote in message
              news:[email protected]..
              > From time to time one of our JSP pages is throwing this error
              >
              >
              > Wed Aug 30 13:56:45 GMT 2000:<E> <ServletContext-General> exception raised
              > on '/
              > Login.jsp'
              > java.net.SocketException: Connection reset by peer: socket write error
              > at java.net.SocketOutputStream.socketWrite(Native Method)
              > at java.net.SocketOutputStream.write(SocketOutputStream.java,
              > Compiled C
              > ode)
              > at
              weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java,
              > Com
              > piled Code)
              >
              >
              > It doesn't do it all the time and it doesn't seem to cause a probelm or
              have
              > any effect on the output on our clients. Can someone tell me what this
              > error is and what I can do about it?
              >
              >
              

  • SocketException reading request, ignored in Tomcat !

    In my application I get sometimes the following Exception :
    ContextManager: SocketException reading request, ignored - java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
         at java.net.SocketInputStream.socketRead(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:86)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:204)
         at org.apache.tomcat.service.http.HttpRequestAdapter.doRead(HttpRequestAdapter.java:115)
         at org.apache.tomcat.core.BufferedServletInputStream.doRead(BufferedServletInputStream.java:106)
         at org.apache.tomcat.core.BufferedServletInputStream.read(BufferedServletInputStream.java:128)
         at javax.servlet.ServletInputStream.readLine(ServletInputStream.java:138)
         at org.apache.tomcat.service.http.HttpRequestAdapter.readNextRequest(HttpRequestAdapter.java:129)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:195)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
         at java.lang.Thread.run(Thread.java:484)
    The Exception occurs not everytime.
    What I am doing is storing some objects in the request object and in the session.
    thanks andi

    Im having something similiar...
    2002-01-31 12:53:19 - ContextManager: SocketException reading request, ignored - java.net.SocketException: Connection reset by peer
    at java.net.PlainSocketImpl.socketAvailable(Native Method)
    at java.net.PlainSocketImpl.socketAvailable(Compiled Code)
    at java.net.PlainSocketImpl.available(Compiled Code)
    at java.net.SocketInputStream.available(Compiled Code)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Compiled Code)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled Code)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)
    Any Idea ?? Thanks !

Maybe you are looking for

  • Can't install Snow Leopard over Ethernet

    Hello, I'm trying to install Snow Leopard remotely on my Macbook Air. I don't have a wireless connection, but was told I could do it using the Ethernet connection. I've connected my MacBook Air to my wife's MacBook using an ethernet cord and the appl

  • Encountered error while starting server. pls guide

    hi, friends i have been getting this error number of times, i have been trying to restart the server and this is repeating. trc file: "dev_disp", trc level: 1, release: "620" Mon Mar 03 17:34:23 2008 systemid   560 (PC with Windows NT) relno      620

  • In i-Pad's Safari PDF opens in same tab

    Hi friends.. In i-Pad's safari browser I want to open PDF in another tab.. right now it's opening in same tab.. Is there any setting for this..?? and one more I am using button for generating PDF.. Also in our application we havent provided the funct

  • IPod stops song, jumps to photos...but its a b&w!

    I'm using an older 20G b&w display (click wheel) My iPod will stop any song I'm listening to and just jump to the "import photos" section. The funny thing is that it doesnt even have a color display. I was shocked to see it had a photo section. Anywa

  • FIDCCP02 IDoc.

    Hi, I found out the Idoc  type that can be used to post the incoming open AR items into SAP(Cash posting) for a requirement. Now how do I map the required filed as per requirement to the IDoc ?? Here IDoc is Target & below details are source. Require