• RELEVANCY SCORE 3.26

    DB:3.26:What Is Connection Programming And How Do I Hook Up Accounting 2009 Professional To My Database To Sell On My Web fd






    Accounting professional should have a database I can drag into Expression 4 web applications so I can collect credit card info; it does it automatically from Ebay?

    Other topic
    NOTE: If you are aware of Unix Sockets then you can leave introduction part
    What is a socket?
    Just another bit of computer jargon? Going back a little into networking history, it is a Berkeley UNIX mechanism of creating a virtual duplex connection between processes. This was later ported on to every known OS enabling communication between systems
    across geographical location running on different OS software. If not for the socket, most of the network communication between systems would never ever have happened.
    Taking a closer look; a typical computer system on a network receives and sends information as desired by the various applications running on it. This information is routed to the system, since a unique IP address is designated to it. On the system, this
    information is given to the relevant applications which listen on different ports. For example a net browser listens on port 80 for information. Also we can write applications which listen and send information on a specific port number.
    For now, let's sum up that a socket is an IP address and a port, enabling connection.
    To explain the socket we will take an example of Client - Server Programming. To complete a client server architecture we would have to go through the following steps
    Creating A Server

    Create a socket with socket call. Bind the socket to a port address with bind call. Listen to the socket at the port address with listen call. Accept client connections with accept call.
    Creating A Client

    Create a socket with socket call. Connect (the socket) to the remote machine with connect call.

    Create a socket
    The first step in establishing a network connection is creating a socket, with the sockt() function

    socket( SOCKET, DOMAIN, TYPE, PROTOCOL ); creates a socket

    socket creates a SOCKET. The other three arguments are integers which should have the following values for TCP/IP connections.

    DOMAIN should be PF_INET. It's probable 2 on your computer. TYPE should be SOCK_STREAM for TCP/IP connection. PROTOCOL should be (getprotobyname('tcp'))[2]. It is the particular protocol such as TCP to be spoken over the socket.

    So socket function call will be something like this:

    use Socket #defines PF_INET and SOCK_STREAM
    socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]);

    Bind to a socket address
    The sockets created by socket are innocent and they have not yet been polluted by a computer hostname or a port number. Next socket function
    bind() fleshes out the socket with these values. Server uses bind() function to specify the port at which they will be accepting connections from the clients.

    bind( SOCKET, ADDRESS ) binds a network ADDRESS to a SOCKET.

    ADDRESS is a socket address which ( for TCP/IP ) is a packet string containing three elements

    The address family (For TCP/IP, that's AF_INET, probably 2 on your system ) The port number ( for example 21 ) The internet address of the computer ( for example 10.12.12.168 )
    As the bind() is used by a server which does not need to know its own address so the argument list looks like this:

    $port = 12345; # the port
    bind( SOCKET, pack( 'Sn4x8', AF_INET, $port, \0\0\0\0 ))
    or die Can't bind to port $port! \n;

    The or die clause is very important - if a server dies without outstanding connections the port won't be immediately reusable unless you use the option SO_REUSEADDR using
    setsockopt() function. Here pack() function is being used to pack all the data into binary format.

    Listening on the port
    If this is a server program then it is required to issue a call to listen() on the specified port.

    listen( SOCKET, QUEUESIZE );

    The above call is mandatory for all the servers and here QUEUESIZE is the maximum number of outstanding connection request allowed. Generally, listen() is used in an infinite loop. As soon as one connection arrives the server deals with it and then goes
    back to listen for more connections.

    Accepting connections
    If this is a server program then it is required to issue a call to access() function to accept the incoming connections.

    accept( NEW_SOCKET, SOCKET );

    The accept call receive SOCKET descriptor returned by socket() function. Upon successful completion of this call, a new socket descriptor is returned. All future communication between client and server then takes place over NEW_SOCKET and SOCKET returns
    to what it does best : listen()ing for a new connection. If access() call fails then it returns FLASE which is defined in Socket module which we have used initially.
    You will often see accept() used inside a while loop as follows

    while(1) {
    accept( NEW_SOCKET, SOCKT );
    .......
    }

    Now all the calls related to server are over and let us see a call which will be required by the client

    Connection Establishment
    If you are going to prepare client program then after using socket() call you would have to use another call
    connect() to connect to the server.

    connect( SOCKET, ADDRESS );

    Here ADDRESS is a socket address similar to bind call, except that it contains the IP address of the remote server.

    $port = 21; # the ftp port
    $server_ip_address = 10.12.12.168;
    connect( SOCKET, pack( 'Sn4x8', AF_INET, $port, $server ))
    or die Can't connect to port $port! \n;

    If you connect to the server successfully then you can start sending your commands to the server using SOCKET descriptor.
    So now lets put all the things together

    Script to Create a Server

    #!/usr/bin/perl -w
    # server.pl
    #--------------------

    use strict;
    use Socket;

    # use port 7890 as default
    my $port = shift || 7890;
    my $proto = getprotobyname('tcp');

    # create a socket, make it reusable
    socket(SOCKET, PF_INET, SOCK_STREAM, $proto)
    or die Can't open socket $!\n;
    setsockopt(SOCKET, SOL_SOCKET, SO_REUSEADDR, 1)
    or die Can't set socket option to SO_REUSEADDR $!\n;

    # bind to a port, then listen
    bind( SOCKET, pack( 'Sn4x8', AF_INET, $port, \0\0\0\0 ))
    or die Can't bind to port $port! \n;
    listen(SOCKET, 5) or die listen: $!;
    print SERVER started on port $port\n;

    # accepting a connection
    my $client_addr;
    while ($client_addr = accept(NET_SOCKET, SOCKET)) {
    # send them a message, close connection
    print NEW_SOCKET Smile from the server;
    close NEW_SOCKET;
    }

    Now starting above Server
    To run the server in background mode issue the following command on Unix prompt

    $sever.pl

    Script to Create a Client

    #!/usr/bin/perl -w
    # client.pl
    #----------------

    use strict;
    use Socket;

    # initialize host and port
    my $host = shift || 'localhost';
    my $port = shift || 7890;
    my $server = 10.12.12.168;

    # create the socket, connect to the port
    socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2])
    or die Can't create a socket $!\n;
    connect( SOCKET, pack( 'Sn4x8', AF_INET, $port, $server ))
    or die Can't connect to port $port! \n;

    my $line;
    while ($line = SOCKET) {
    print $line\n;
    }
    close SOCKET or die close: $!;

    http://www.tutorialspoint.com/perl/perl_socket.htm
    Accounting professional should have a database I can drag into Expression 4 web applications so I can collect credit card info; it does it automatically from Ebay?

    DB:3.26:What Is Connection Programming And How Do I Hook Up Accounting 2009 Professional To My Database To Sell On My Web fd

    This is an Expression Web forum. .. Not an Accounting Professional forum, a Unix forum, or a database forum. I didn't see anything in your post related to something done in EW.

  • RELEVANCY SCORE 3.24

    DB:3.24:Serversocket Choosing Different Socket Than The One Specified sc





    I have this application on solaris (1.4.1 VM) where I am opening a server socket with a specified port, the problem is that after I create the server socket and I make a call on the server socket instance with the method getLocalPort() it returns a different port. I have tried creating a ServerSocket with all the specified constructors (also with the bind(SocketAddress)), but still ends up choosing this other port. What could be going on wrong?

    Thank You

    DB:3.24:Serversocket Choosing Different Socket Than The One Specified sc


    It appears to be working correctly for me - can you post a test case and show the output of getLocalPort.

  • RELEVANCY SCORE 3.22

    DB:3.22:Thread: Cannot Bind To Lpd Port 631 xm





    I removed cups and installed lpdfilter and lprng to use lpd.

    When I start lpd I get following error cannot bind to lpd port 631

    I changed following in /etc/lpd.conf

    Lpd_port=632

    But I still get the error cannot bind to lpd port 631

    How can I change the ipp port for lpd so I can use iprint and lpd on the

    same server.

    DB:3.22:Thread: Cannot Bind To Lpd Port 631 xm

    Mark Robinson wrote:

    Toine van Eijk wrote:

    I removed cups and installed lpdfilter and lprng to use lpd.

    Is there any particular reason why that is necessary?

    When I start lpd I get following error cannot bind to lpd port 631

    I changed following in /etc/lpd.conf

    Lpd_port=632

    But I still get the error cannot bind to lpd port 631

    How can I change the ipp port for lpd so I can use iprint and lpd on the

    same server.

    Haven\'t got a way of testing it just now, but you could try adding a second

    IP address and seeing if you can use lpd on that IP address.

    It would be better to find out what is causing the problem. For a

    start, try this: netstat -tupln|grep 631

    Paul

  • RELEVANCY SCORE 3.15

    DB:3.15:Rmi And Ssl -≫ A Big Problem!!! 79


    hi,
    i have built an application which communicate with applets over RMI. Now, I would like to encrypt the channel
    with SSL.

    constructor-call:
    ...
    super(0, new RMISSLClientSocketFactory(), new RMISSLServerSocketFactory());
    ...

    Client-Socket-class:

    public class RMISSLServerSocketFactory implements RMIServerSocketFactory, Serializable{
    public ServerSocket createServerSocket(int port) throws IOException{
    SSLServerSocketFactory fact = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    return fact.createServerSocket(port);
    }}

    Server-Socket-Class:
    public class RMISSLClientSocketFactory implements RMIClientSocketFactory, Serializable{
    public Socket createSocket(String host, int port) throws IOException{
    SSLSocketFactory fact = (SSLSocketFactory) SSLSocketFactory.getDefault();
    return fact.createSocket(host, port);
    }}

    Registry-binding:
    Naming.rebind("Server", svr)

    When I use this code, I can create the object instance.
    I can also bind it into the registry. However, it only waits a few seconds and then exits.

    when i bind the object in the rmiregistry as followed:
    ...
    Registry reg = LocateRegistry.createRegistry(1099);
    reg.rebind("Server", svr);
    ...

    the server runs without problems - but its not possible to connect the rmiregistry from client:
    ...
    Naming.rebind("//127.0.0.1:1099/Server");
    or
    Registry reg = LocateRegistry.getRegistry("127.0.0.1", 1099);
    reg.rebind("Server");
    ...

    the client/server throws no exception - the lookup-method doesnt work - why???
    i think the problem makes the ssl-sockets, but i'm not sure!!!

    (if i kill the server - ...connection refused to host 127.0.0.1....)

    whats the problem????????? - any idea

    mike

    DB:3.15:Rmi And Ssl -≫ A Big Problem!!! 79

    ohhh sorry,
    i know:
    ...
    Naming.lookup("//127.0.0.1:1099/Server");
    or
    Registry reg = LocateRegistry.getRegistry("127.0.0.1",
    1099);
    reg.lookup("Server");
    ...

    mike

  • RELEVANCY SCORE 3.13

    DB:3.13:Client Socket Not Detecting When Serversocket Is Closed zd


    // Simple server application:
    ServerSocket serverSocket = new ServerSocket(port);
    Socket clientSocket = serverSocket.accept();
    InputStreamReader isr = clientSocket.getInputStream();
    //... read inputs from client...
    isr.close();
    clientSocket.close();
    serverSocket.close();

    // Simple client application:
    Socket socket = new Socket(hostname, port);
    OutputStream os = socket.getOutputStream();
    // ... write a bunch of bytes using os.write() and then os.flush()
    os.close();
    socket.close();My problem is when the server application goes down for any reason, the client application does not get any indication at all; the writes continue without any exceptions. I even tried before each write, checking socket.isConnected(), socket.isOutputShutdown(), socket.isClosed(), and they all seem to indicate nothing is wrong.

    Is there any way for a client socket to determine if the socket it connected to is down? My other option is to add acknowledgements, but I am not in a position to modify the real server application code.

    Thanks.

    DB:3.13:Client Socket Not Detecting When Serversocket Is Closed zd

    See reply #2 in http://forum.java.sun.com/thread.jspa?threadID=5186321tstart=0
    and reply #5 in http://forum.java.sun.com/thread.jspa?threadID=5186761tstart=0.

  • RELEVANCY SCORE 3.08

    DB:3.08:Lwip Client On Zc702 [Rst,Ack] Received sx



    Hi All,

    I am trying to add some networking capabilities to my ZC702 design. I have PC running a Server and ZC702 running a LWIP-TCP Client. Following is my LWIP client side code snippet

    1) I bind local lwip socket to IP address 192.168.1.10 on port 8888

    2) I bind the remote server to IP address 192.168.1.100 on port 8888 and listen to any incoming connections

    3) lwip client calls tcp_connect()

    4)In the callback function connected to tcp_connect I try to send some data to the remote server by calling tcp_write()

    int custom_application(){
    struct tcp_pcb *pcb;
    err_t err;
    u16_t port = 8888;
    //ip_addr_t server_ip;
    //ip_addr_t local_ip;

    struct ip_addr server_ip,local_ip;

    /* create new TCP PCB structure */
    pcb = tcp_new();
    if (!pcb) {
    xil_printf("Error creating PCB. Out of Memory\n\r");
    return -1;
    }

    IP4_ADDR(server_ip, 192, 168, 1, 100);
    IP4_ADDR(local_ip, 192, 168, 1, 10);

    //server_ip.addr = inet_addr("192.168.1.100");
    //local_ip.addr = inet_addr("192.168.1.10");

    err = tcp_bind(pcb, (ip_addr_t *)local_ip, port);
    if (err != ERR_OK) {
    xil_printf("Unable to bind to port %d: err = %d\n\r", port, err);
    return -2;
    }

    /* we do not need any arguments to callback functions */
    tcp_arg(pcb, NULL);

    if(tcp_connect(pcb, (ip_addr_t*)server_ip,port,connected_callback) != ERR_OK){
    xil_printf("Error in connection");
    return -1;
    }

    }

    connected_callback code

    err_t connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err){
    char* msg = "Get Data";
    xil_printf("Connection Established");

    tcp_recv(tpcb, recv_callback);

    if(tcp_write(tpcb,msg,sizeof(msg),1) != ERR_OK){
    xil_printf("Error in Sending Data to Server");
    }

    if(tcp_output(tpcb) != ERR_OK){
    xil_printf("Error in Sending Data to Server");
    }

    return ERR_OK;
    }

    Now the usual handshake to setup TCP should be as follows

    CLIENT SERVER

    SYN -------------------

    ------------------ SYN/ACK

    ACK --------------------

    But I receive an additional RST/ACK packet from the remote server which probably closes the connection.

    -------------------------------------------

    | ------------------ RST/ACK |

    ---------------------------------------------

    Shown below is the snapshot captured from wireshark.

    Server IP = 192.168.1.100

    LWIP Client IP = 192.168.1.10

    Could any of you suggest if I may have faltered in some settings ? Or anything else that could have possibly gone wrong ?

    PS: I have tested the same server for a PC socket client transfer and it is responding as expected without sending any RST/ACK packets. Also attaching my complete source file running on ZC702

    Thank you










    Attachments:







    main.c ‏5 KB

    DB:3.08:Lwip Client On Zc702 [Rst,Ack] Received sx


    Hi All,

    I am trying to add some networking capabilities to my ZC702 design. I have PC running a Server and ZC702 running a LWIP-TCP Client. Following is my LWIP client side code snippet

    1) I bind local lwip socket to IP address 192.168.1.10 on port 8888

    2) I bind the remote server to IP address 192.168.1.100 on port 8888 and listen to any incoming connections

    3) lwip client calls tcp_connect()

    4)In the callback function connected to tcp_connect I try to send some data to the remote server by calling tcp_write()

    int custom_application(){
    struct tcp_pcb *pcb;
    err_t err;
    u16_t port = 8888;
    //ip_addr_t server_ip;
    //ip_addr_t local_ip;

    struct ip_addr server_ip,local_ip;

    /* create new TCP PCB structure */
    pcb = tcp_new();
    if (!pcb) {
    xil_printf("Error creating PCB. Out of Memory\n\r");
    return -1;
    }

    IP4_ADDR(server_ip, 192, 168, 1, 100);
    IP4_ADDR(local_ip, 192, 168, 1, 10);

    //server_ip.addr = inet_addr("192.168.1.100");
    //local_ip.addr = inet_addr("192.168.1.10");

    err = tcp_bind(pcb, (ip_addr_t *)local_ip, port);
    if (err != ERR_OK) {
    xil_printf("Unable to bind to port %d: err = %d\n\r", port, err);
    return -2;
    }

    /* we do not need any arguments to callback functions */
    tcp_arg(pcb, NULL);

    if(tcp_connect(pcb, (ip_addr_t*)server_ip,port,connected_callback) != ERR_OK){
    xil_printf("Error in connection");
    return -1;
    }

    }

    connected_callback code

    err_t connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err){
    char* msg = "Get Data";
    xil_printf("Connection Established");

    tcp_recv(tpcb, recv_callback);

    if(tcp_write(tpcb,msg,sizeof(msg),1) != ERR_OK){
    xil_printf("Error in Sending Data to Server");
    }

    if(tcp_output(tpcb) != ERR_OK){
    xil_printf("Error in Sending Data to Server");
    }

    return ERR_OK;
    }

    Now the usual handshake to setup TCP should be as follows

    CLIENT SERVER

    SYN -------------------

    ------------------ SYN/ACK

    ACK --------------------

    But I receive an additional RST/ACK packet from the remote server which probably closes the connection.

    -------------------------------------------

    | ------------------ RST/ACK |

    ---------------------------------------------

    Shown below is the snapshot captured from wireshark.

    Server IP = 192.168.1.100

    LWIP Client IP = 192.168.1.10

    Could any of you suggest if I may have faltered in some settings ? Or anything else that could have possibly gone wrong ?

    PS: I have tested the same server for a PC socket client transfer and it is responding as expected without sending any RST/ACK packets. Also attaching my complete source file running on ZC702

    Thank you










    Attachments:







    main.c ‏5 KB

  • RELEVANCY SCORE 3.03

    DB:3.03:Recieving Through A Proxy jz


    Hi.

    I'm trying to realize a piece of code which enables it so receive connections through a proxy (e.g. SOCKS).
    If I connect to a SOCKS proxy, I can open a port on this server via the BIND command. Suppose I have a little
    HTTP server, realized like the regular way with a plain ServerSocket.
    What I'd like to do is to point every request which is made via the SOCKS proxy, over the port I just opened, to the HTTP server.

    What would be the right way to do this?

    My guess would be like this

    ServerSocket ss = new ServerSocket(1212);
    Socket control = new Socket("localhost", 1081);
    control.SENDBINDCOMMAND();
    ....bind ok
    --connect the two sockets somehow--
    while (true) {
    Socket s = ss.accept();
    System.out.println("accepted");
    stuff(s);
    }regards,
    eeknay

    Edited by: eeknay23 on Sep 11, 2008 12:01 PM

    DB:3.03:Recieving Through A Proxy jz

    Hi.

    I'm trying to realize a piece of code which enables it so receive connections through a proxy (e.g. SOCKS).
    If I connect to a SOCKS proxy, I can open a port on this server via the BIND command. Suppose I have a little
    HTTP server, realized like the regular way with a plain ServerSocket.
    What I'd like to do is to point every request which is made via the SOCKS proxy, over the port I just opened, to the HTTP server.

    What would be the right way to do this?

    My guess would be like this

    ServerSocket ss = new ServerSocket(1212);
    Socket control = new Socket("localhost", 1081);
    control.SENDBINDCOMMAND();
    ....bind ok
    --connect the two sockets somehow--
    while (true) {
    Socket s = ss.accept();
    System.out.println("accepted");
    stuff(s);
    }regards,
    eeknay

    Edited by: eeknay23 on Sep 11, 2008 12:01 PM

  • RELEVANCY SCORE 3.02

    DB:3.02:Not Able To Connect Remotely For Administration On Port 9990 1m



    Hi,

    I am trying to set monitoring for Jboss from remote monitoring application. But I am not able to connect on port 9990 etc

    I went on the Jboss server and tried to telnet on the IP address on port 9990 but it does not work, but I can telnet to localhost on port 9990.

    My standalone .xml has following config

    interfaces

    interface name="management"

    inet-address value="${jboss.bind.address.management:127.0.0.1}"/

    /interface

    interface name="public"

    inet-address value="${jboss.bind.address:127.0.0.1}"/

    /interface

    !-- TODO - only show this if the jacorb subsystem is added --

    interface name="unsecure"

    !--

    ~ Used for IIOP sockets in the standard configuration.

    ~ To secure JacORB you need to setup SSL

    --

    inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/

    /interface

    /interfaces

    socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"

    socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/

    socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/

    socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/

    socket-binding name="ajp" port="8009"/

    socket-binding name="http" port="8080"/

    socket-binding name="https" port="8443"/

    socket-binding name="osgi-http" interface="management" port="8090"/

    socket-binding name="remoting" port="4447"/

    socket-binding name="txn-recovery-environment" port="4712"/

    socket-binding name="txn-status-manager" port="4713"/

    outbound-socket-binding name="mail-smtp"

    remote-destination host="localhost" port="25"/

    /outbound-socket-binding

    /socket-binding-group

    We start the Jboss with -b (Prod IP address)

    I tried to add another interface to standalone that xml

    interface name="any"

    any-ipv4-address/

    /interface

    and changed socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}" to

    socket-binding-group name="standard-sockets" default-interface="any" port-offset="${jboss.socket.binding.port-offset:0}"

    restarted the application with -b 0.0.0.0 but still not able to connect on port 9990

    In the logs I can see "Admin console listening on http://127.0.0.1:9990"

    Help will be appreciated.

    Regards

    Santosh

    DB:3.02:Not Able To Connect Remotely For Administration On Port 9990 1m


    Hi Jai,

    I needed some more help here.

    My Jboss has two interfaces (Prod and Management).

    I started jboss ( standalone.sh -b prod_ip -bmanagement management_ip ), Jboss started and I was able to connect to admin console on port 9990 from remote machine.

    The applications are working good.

    But I started seeing the following errors for all WAR applications

    "(HttpManagementService-threads) JBAS014612: Operation ("read-attribute") failed - address: (["

    What can be the reason ?

    Help will be appreciated

    Regards

  • RELEVANCY SCORE 3.01

    DB:3.01:Error Starting Ormi-Server. Unable To Bind Socket: Address Already In Use: 81


    hi,
    I run the folowing command "start_oc4j.bat" to start Oc4j.
    It starts successfully.
    Then I start "BPEL PM Server".

    I get the following error,
    "Error starting ORMI-Server. Unable to bind socket: Address already in use: JVM_Bind".

    I understand the above errror because both of them are trying to bind to the same port. And both of them are trying to start ORMI server. Can some one suggest how to get rid of this problem.

    I tried giving different port numbers for them, but that did not work. Let me know, how to over come this problem.

    with regards
    shaila

    DB:3.01:Error Starting Ormi-Server. Unable To Bind Socket: Address Already In Use: 81

    You may have another OC4J running on your computer.
    You should change the port number in the file config/rmi.xml.

  • RELEVANCY SCORE 3.00

    DB:3.00:Re: Will This Setup Work? a9


    No. The ServerSocket just creates sockets when a client connects. It itself does not communicate.

    It's like the post office. The post office routes mail, but the delvery person does. Or the phone company routes your phone call, but only your phones communicate.

    You don't need to transfer the socket, just have a thread that acts on connections.

    The basic multi-threaded server (which you can search for in the forums), is easy.

    1. Create Server Socket
    2. Create a Thread that handles ServerSocket.accept()

    When a client connects to the server, a NEW socket object is automatically created and is then handled by the thread which allows the Server to accept another connection in its thread while the other thread works with its client.

    Transfering a Socket A to Socket B and then setting Socket A to null, would not be the best practice - but would work.

    Any data that is sent between sockets is bound to the source-desitination port, and that port is unique to each instance, therefore, transfering that socket to a new instance would bind the new object to that port and nullifying the old socket would simply trash the old object in memory.

    The server socket listens on a port, but does not transmit on any port - it just creates sockets.

    When a web browser connects to a web server on port 80, the socket created actually links the server port xxxx with the source port on the client machine. 'xxxx' is a random or seq. open port on the server.

    To see how this works, make a socket to port 80 of some web server, then display the remote port that you are actually connected to - it will be some large number - not the 80 that you originally connected to.

    If this didn't happen - the a server could only communicate with a single client at any given time - and therefore would not be very useful in networks.

  • RELEVANCY SCORE 3.00

    DB:3.00:Winsock Dgram Socket Bind() Bug 7s


    Hi,I think that I found a bug in Vista winsock implementation, I'm not sure where to report, so I'll post it here.

    Description:

    If bind() call on datagram socket returns that scocket is in use WSAEADDRINUSE (10048), then next call of bind() on the same socket on a free port returns WSAEINVAL (10022) i.e socket is bound already.

    How to reproduce:
    Write a simple program that opens 2 datagram sockets, bind one of them
    on a free port, then bind the second socket on the same port, so you'll
    get WSAEADDRINUSE, then try to bind the second
     socket on a free port and you'll get WSAEINVAL.Test case: WSADATA wsaData;  int iResult = WSAStartup(MAKEWORD(2,2), wsaData);    SOCKET Socket1 = socket(PF_INET, SOCK_DGRAM, 0);   SOCKET Socket2 = socket(PF_INET, SOCK_DGRAM, 0);   sockaddr_in service;  service.sin_family            = AF_INET;  service.sin_addr.s_addr = inet_addr(127.0.0.1);  service.sin_port                = htons(27015);  if (bind( Socket1, (SOCKADDR*) service, sizeof(service)) 0)   {    cout bind() failed. endl;  }  else  cout bind() success! endl;   // will fail with WSAEADDRINUSE  if (bind( Socket2, (SOCKADDR*) service, sizeof(service)) 0)   {    cout bind() failed. WSAGetLastError() endl;  }  else  cout bind() success! endl;    service.sin_port = htons(27016);    //shouldnot fail, but it fails with WSAEINVAL  if (bind( Socket2, (SOCKADDR*) service, sizeof(service)) 0)   {    cout bind() failed. WSAGetLastError() endl;  }  else  cout bind() success! endl;    closesocket(Socket1);  closesocket(Socket2);  WSACleanup();

    DB:3.00:Winsock Dgram Socket Bind() Bug 7s

    We had this problem - McAfee installed on Vista changed the behaviour of bind. A UDP socket could not be reused if the first port tried was unavailable. I raised an issue with McAfee and they eventually suggested I try the Microsoft Hotfix KB961775. See http://support.microsoft.com/kb/961775 This seems to have solved the problem for me. I think the hotfix was first made available in February 2009, so it only took two years for a patch to be rushed out. And while McAfee definitley triggered the problem (and appeared guilty), it was a Microsoft issue all along. The next question is when this patch gets rolled into the recommended patches...

  • RELEVANCY SCORE 2.99

    DB:2.99:Secure Socket Over Regular Socket (Jsse) For Server j9


    Hello!

    I have some guestion i hope u will understand.. i am building a server/clients application with secure connection.. i have done a server who init secure socket before it gets the clients.. and problem here is that server reads just one public key from all client the public key and private client key must be the same in all clients.. so i wanna create server that listening on port with regular socket and when connection is accepted from port who we listening at, is bind to some other port that is secure.. is this posebile to override regular seocket with sslsocket when connection is allredy running?

    i hope u undestand what i wanna know!

    Thx for answers!

    DB:2.99:Secure Socket Over Regular Socket (Jsse) For Server j9

    You can do this but you don't need the extra port. At the server end just accept a Socket from ServerSocket.accept(), do your initial thing, then when you want to make the connection secure turn the Socket into an SSLSocket:

    SSLSocket sslSocket = (SSLSocket)SSLSocketFactory.getDefault().createSocket(socket,,socket.getInetAddress().getHostName(),socket.getPort(),true);
    sslSocket.setUseClientMode(false);

    At the client, create a Socket via a standard Socket constructor, do your initial thing, then turn it into an SSLSocket the same way, this time setting useClientMode to true.

  • RELEVANCY SCORE 2.95

    DB:2.95:Olt-Error: "Fail To Bind Socket To Local Port 0" d8


    Hello,

    We have set up a new agent-machine, a Windows Server 2008. Some (not all, which is strange) of the VU:s get the following error:

    "Failed to bind socket to local port 0. Caused by: java.net.SocketException occurred. Error Message: Address family not supported by protocol family: bind".

    Any settings that has to be done? Please advice.

    Edit: When running only two VU:s of the same script, the first is OK, the second fails.

    Regards
    Alex

    Edited by: ao on 2011-apr-21 08:47

  • RELEVANCY SCORE 2.95

    DB:2.95:Server Not Starting On Aix 9c


    Been using WLS for a long time (9.2.x, 10.3 etc. Multiple platforms)
    Servers are created by standard WLST scripts. And we moved from 10.3 to 10.3.3 very recently and everything worked on Windows. On AIX (64 bit java, 64 bit WLS) we are getting a port binding issue. Tried two separate AIX boxes. 7001 on one and 4199 on other. The error message when the server comes up is as follows. I tried giving a Listen Address of 127.0.0.1 and still did not work.

    Any thoughts?

    ####Aug 18, 2010 10:25:24 PM EDT Emergency Security xxxxx.dev.corp.local AdminServer [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.De
    fault (self-tuning)' WLS Kernel 1282184724899 BEA-090087 Server failed to bind to the configured Admin port. The port may already be used by another process.
    ####Aug 18, 2010 10:25:24 PM EDT Error Server xxxxxx.dev.corp.local
    AdminServer DynamicListenThread[Default] WLS Kernel 128218472490
    0 BEA-002606 Unable to create a server socket for listening on channel "Default". The address 10.0.9.142 might be incorrect or another process is using port 4199: java.net.BindException: The socket name is already in use..
    ####Aug 18, 2010 10:25:24 PM EDT Error Server xxxxxx.dev.corp.local
    AdminServer DynamicListenThread[Default[2]] WLS Kernel 128218472
    4900 BEA-002606 Unable to create a server socket for listening on channel "Default[2]". The address 0:0:0:0:0:0:0:1 might be incorrect or another process is
    using port 4199: java.net.BindException: The socket name is already in use..
    ####Aug 18, 2010 10:25:24 PM EDT Critical WebLogicServer xxxxx.dev.corp.local AdminServer main WLS Kernel
    1282184724900 BEA-000362
    Server failed. Reason: Server failed to bind to any usable port. See preceeding log message for details.

    DB:2.95:Server Not Starting On Aix 9c

    Bad java install! Missing policy files. Thanks everyone.

  • RELEVANCY SCORE 2.93

    DB:2.93:Error Connecting To Tcp Listener Socket On Same Machine cj


    Hi pals,
    I have a problem which is driving me mad. I
    am using a TCP socket to listen for incoming connections and another TCP socket to connect to this socket asnychronously. here is the code snippet:
     
    The server socket on a new thread:
    Private Sub StartListening()
    'create listening socket
    tcpServer = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
    ListeningDone.Reset()
    Try 'bind listening socket to port
    While True
    tcpServer.Bind(Me.LocalEndPoint)
    tcpServer.Listen(500)
    tcpServer.BeginAccept(New AsyncCallback(AddressOf AcceptCallback), tcpServer)
    ListeningDone.WaitOne()
    End While
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub
    ...
    For the client connection on another thread:
    Private Sub ConnectClient()
    Dim remoteEP As IPEndPoint = New IPEndPoint(Me.LocalIPAddress, 11000) 'create local end point
    ' Create client TCP/IP socket.
    tcpClient = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
    ' Connect to the remote endpoint.
    Try
    ConnectDone.Reset()
    tcpClient.BeginConnect(remoteEP, AddressOf ConnectCallback, tcpClient)
    ConnectDone.WaitOne()
    ....
    However when trying to connect to this listening port, I get this error:
    No connection could be made because target computer actively denies connection
    Please help me out on this,
    Thanks

    DB:2.93:Error Connecting To Tcp Listener Socket On Same Machine cj

    Thanks for the quick help
    I will try it out tomorrow
    and inform you as fast as possible on any related problems. U r a great pal

  • RELEVANCY SCORE 2.92

    DB:2.92:Several Process Listening To The Same Port Number kj


    I have server/client application, the server create a socket, bind to this socket and then listen to this socket.
    after that in a while(1) loop he wait for accept:
    int sockclient = accept(sockId,(struct sockaddr*)(client_addr), addrLen);

    when the server get a sockclient he create new process (fork()) that handle the client request.

    I would like to know if there is a problem that several processes (parent and several child processes) are listening to the same port, is it better to create thread that would handle the client request, instead of creating a child process?

    struct sockaddr_in addr, client_addr;
    bzero(addr,sizeof(struct sockaddr_in));

    addr.sin_family = PF_INET;
    addr.sin_port = 8865;
    bcopy(ent-h_addr_list[0],(addr.sin_addr), ent-h_length);

    // bind
    bind(sockId,(struct sockaddr*)(addr), sizeof( struct sockaddr_in));

    If it would help I can add the all code.

    DB:2.92:Several Process Listening To The Same Port Number kj

    I'm not sure about this one. You will have better luck
    asking this question on one of the Solaris-related forums.
    The people who read those forums have more expertise
    on problems like this.

  • RELEVANCY SCORE 2.92

    DB:2.92:Re-Bind()Ing To A Tcp Port Right After A Crash? kx


    Hi all,

    The following is a scenario I run into all the time:

    1) A TCP/IP server starts up, creates a socket, and bind()s to TCP port XXXX.

    2) A TCP/IP client connect()s to the server at port XXXX, the server accept()s the connection, and data starts flowing across the connection.

    3) The server is either interrupted (Ctrl-C) or crashes before the client disconnects.

    4) The client detects this, close()s the socket on its end of the connection, and exits (or goes into a loop where it tries to re-connect() to the server).

    5) I try to restart the server, but I get a message like "can't bind to port XXXX". The call to bind() returns -1 with errno set to EADDRINUSE. In the call to bind(), I specify INADDR_ANY (0.0.0.0) for the IP address.

    6) Several minutes have to pass before the server will successfully bind to port XXXX again.

    This suggests that some sort of timeout elapses before a bound-to port is considered available again (after an application bound to that port crashes). Is there any way to shorten the timeout or reset the status of the port?

    Or, would passing an IP address other than INADDR_ANY to bind() fix this (in that case, what should I specify)?

    Thanks in advance for any help,

    -Constantine

    DB:2.92:Re-Bind()Ing To A Tcp Port Right After A Crash? kx

    Hello.
    Under Linux there is a similar problem: Once a port has been used it cannot (or only after a long delay) be used again. This means after the server has been stopped it cannot be started again even if the socket has been close()d correctly.
    The simple solution is to make the socket "reusable". This is done by using setsockopt(...,SO_REUSEADDR,...) before bind()ing it. The great disadvantage is: Two (or more) servers can use the same port at the same time. In this case only one of the two servers will get an incoming TCP connection using accept().
    The way out would be to check if the server is already running...
    Martin.

  • RELEVANCY SCORE 2.91

    DB:2.91:Able To Bind To The Same Port On Twice With Setsocketoptionreuseaddress z1


    Hi,

    I am not sure wether it is bug in API or lack in understanding.

    I have a server , using Java networking API and I have set "setSocketOptionReuseAddress(true)" for "java.net.ServerSocket". Now I am able to start more than one instances of server with same port and IP.

    If I set "setSocketOptionReuseAddress" to false. second instance won't start an throws 'Address in user : bind exception".

    setSocketOptionReuseAddress is supposed to help only in socket "TIME_WAIT" situation, why is bind getting effected by this?

    DB:2.91:Able To Bind To The Same Port On Twice With Setsocketoptionreuseaddress z1

    I assume the original poster is on Windows in which case the SO_REUSEADDR socket option has different semantics for streams socket compared to other platforms. As the poster says, it allows multiple servers to bind to the same socket. Assuming this is a ServerSocket then the simplest solution would be not use setReuseAddress -- ie: leave it as its default value and everything should be fine. On Windows you can re-bind when a previous connection is in TIME_WAIT. On other platforms (Solaris/Linux anyway), the SO_REUSEADDR option is enabled by default for ServerSockets so the server can be restarted even if there is a connection in TIME_WAIT.

  • RELEVANCY SCORE 2.91

    DB:2.91:Ormi Server Not Starting Properly 1c


    Hello Developers

    I have a messaging application that uses JMS for message passing between different legacy application.

    It runs fine on standalone OC4J. But the moment I use enterprise manager, the oc4j keeps on complaining that it cannot start the ormi server (having socket bind problems)..and this in effect won't allow my messaging application to start. Even when I go to the rmi.xml file and change the port, it will still complain about the socket.

    I have read on some other user forums that there are developers out here who have the same problems..is there a fix to it.. or should orcale start professing using oc4j standalones in production enviroment.

    Regards

    Rathin

    DB:2.91:Ormi Server Not Starting Properly 1c

    Try running "netstat -an" to see if there are any ports opened which might fall to range of ports specified for OC4J container.

    Also, for RMI in version 9.0.3 there is only one port opened from specified range, you are more lucky to specify range of 1 (like 3150-3150).
    Second, ranges might overlap with each other, check this.

    Last, on production site there are mostly more containers, check their ranges of ports - if default range is let's say 3100-3110 and there are 11 containers, one of them probably won't start since there will be no free port left...

    Myrra

  • RELEVANCY SCORE 2.91

    DB:2.91:Enabling Ssl For Web Services k8



    Hi everyone,

    I'm trying to enable SSL for a web service deployed to JBoss AS 7.2.0, following the guide from https://docs.jboss.org/author/display/AS71/SSL+setup+guide but the web service is still getting deployed to http://ip_address:8080 and there is nothing at https://ip_address:8443

    I feel like I am missing something somewhere but all my Googling has not turned up any leads.

    Snippet from standalone.xml:

    subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false"

    connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/

    connector name="https" scheme="https" protocol="HTTP/1.1" socket-binding="https" enable-lookups="false" secure="true"

    ssl name="f4698010" password="changeit" protocol="TLSv1" key-alias="f4698010" certificate-key-file="D:\Users\f4698010\mykeystore\f4698010.keystore" /

    /connector

    virtual-server name="default-host" enable-welcome-root="true"

    alias name="localhost"/

    alias name="example.com"/

    /virtual-server

    /subsystem

    subsystem xmlns="urn:jboss:domain:webservices:1.2"

    modify-wsdl-addresstrue/modify-wsdl-address

    wsdl-host${jboss.bind.address:10.202.15.40}/wsdl-host

    endpoint-config name="Standard-Endpoint-Config"/

    endpoint-config name="Recording-Endpoint-Config"

    pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM"

    handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/

    /pre-handler-chain

    /endpoint-config

    client-config name="Standard-Client-Config"/

    /subsystem

    socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"

    socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/

    socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/

    socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/

    socket-binding name="ajp" port="8009"/

    socket-binding name="http" port="8080"/

    socket-binding name="https" port="8443"/

    socket-binding name="messaging" port="5445"/

    socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/

    socket-binding name="messaging-throughput" port="5455"/

    socket-binding name="remoting" port="4447"/

    socket-binding name="txn-recovery-environment" port="4712"/

    socket-binding name="txn-status-manager" port="4713"/

    outbound-socket-binding name="mail-smtp"

    remote-destination host="localhost" port="25"/

    /outbound-socket-binding

    /socket-binding-group

    Any advice would be great.

    Regards and thanks

    Victor

    DB:2.91:Enabling Ssl For Web Services k8


    Turns out this was caused by me using a self signed certificate which is not trusted by Chrome, I was testing the SSL via Advanced REST Client in Chrome and did not click 'Proceed Anyway' in order to get it ignore the fact that it's not a trusted certificate.

  • RELEVANCY SCORE 2.90

    DB:2.90:How Do I *Not* Inherit Listening Socket? 8z


    I have a service that listens on a port.  This service also creates processes that execute other unrelated code.  The listening socket is being inherited by the created processes.  This causes a problem if the service fails or is restarted because the created processes are still running and the new instance of the service can't bind to the port because it's in use.
     
    I don't need to have the created processes inherit the socket but, I do need to have them inherit other handles so, I can't set InheritHandles to false in the call to CreateProcess...  I have no control over the code that the created processes run so, I can't close the inherited socket.
     
    How can I disable inheritance on the listening socket?  Or, is there another solution?
     
    Thanks,
     
    John Vottero
     
     

    DB:2.90:How Do I *Not* Inherit Listening Socket? 8z

    I ran into the same problem and resolved it by pinvoking SetHandleInformation (kernel32.dll) and zeroing the HANDLE_FLAG_INHERIT bit (that's bit 1) on the Socket.Handle in the parent process. The child processes should no longer inherit the
    socket and therefore won't keep the port open when the parent exits.

    I implemented this on my sockets, and this prevented them from being inherited. (Pardon me while I am over-joyed after so many years *HOORAY*)If you can't astound 'em with brilliance... err you can't?

  • RELEVANCY SCORE 2.89

    DB:2.89:Little Information About Winsock Required pd


    Hi I did ome network programming in .net and i have started in C== i have got my project up and running but i need a little bit of information about the host . currently i know how to establish a connection , send ,receive, ,file transfer etc. the simple code which i have created is: //Winsock Startup WSADATA ws; WSAStartup(0x0202,ws); //DEFINE THE SERVER - Control Panel PARAMETERS ControlPanel_mystruct.sin_family = AF_INET; ControlPanel_mystruct.sin_port =  htons(5050); //Port Address ControlPanel_mystruct.sin_addr.s_addr = inet_addr(IP_Control_Panel); //Internet Address //SOCKET FUNCTION GET NEW SOCKET DESCRIPTOR - RETURN HANDLE TO SERVER myclient[0] = socket(AF_INET,SOCK_STREAM,0); //Establish Connection if (connect(myclient[0],(struct sockaddr*) ControlPanel_mystruct,sizeof(ControlPanel_mystruct))!= -1)   //Blocking Function         {         cout Connection Esablished         } Anyways as you can see In my server code I know that I am suppose to bind to a port but i am not doing that still my program works. could you tell me what are my losses , if i dont bind and what its importance it.Furthermore how can i obtain the different ip address of the host. i was wandering if anyone could explain a quick gethostbyname and its usage to obtain ipaddress. thanks A candle loses nothing by lighting another candle.

    DB:2.89:Little Information About Winsock Required pd

    @Wyck you were correct.. that was the client code.. had it mixed up Thanks anywaysA candle loses nothing by lighting another candle.

  • RELEVANCY SCORE 2.88

    DB:2.88:Why A Udp Socket Needs To Be Bound To The Localendpoint For Sending? jd


    I need to share the local EndPoint with multiple process (web pages sending UDP commands to remote devices).In the backend I have a single Listener bound to the magic port.The Web pages instantiate the UdpClient class and without calling the Bind method, they invoke the SentTo function.Using a sniffer, I see the datagram for the EndPoint but the device does not get the message.Oddly enough, if I bound the socket then the remote device gets the datagram.More precise:If the remote device is a WINCE machine, to send a UDP message I need to bind the UDP socket to the localEndPoint (I suspect this is needed to establish the Network Interface).But If I use another embedded device, the same code works without having to bind the UDP socket.This application talks to GPRS devices on the fields and sends simple commands from a web page.We have old generation devices implementing the IP stack (not MS) but they get the commands without any problemNew devices based on WinCE are listening using on teh same remote port, but they never get the datagram unless the server has its own LocalEndPoint bound.The problem about binding the socket is that the UDP listener is already bound (and this one is always running as it is the broker for all the responses), but if I try to bind the senders on the fly they complain about only: Only one usage of each socket address (protocol/network address/port) is normally permittedIs the problem clear? does it belong here or on WinCe forums?

    DB:2.88:Why A Udp Socket Needs To Be Bound To The Localendpoint For Sending? jd

    The endpoint set by connect affects both outgoing and incoming packets. :-,)  http://msdn.microsoft.com/en-us/library/ms737625(VS.85).aspx in particular the second sentence:
    For a connectionless socket (for example, type SOCK_DGRAM), the operation performed by connect is merely to establish a default destination address that can be used on subsequent send / WSASend and recv / WSARecv calls. Any datagrams received from an address other than the destination address specified will be discarded.
    When it says address it means socket address=sockaddr=sockaddr_in i.e. address+port.
    (BTW are packets sent in both directions?)http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, mark the question answered

  • RELEVANCY SCORE 2.88

    DB:2.88:Error While Working On Oc4j Installation And Configuration cd


    Hi i am using DB(9.2.0.6.0) and APPS(11.5.10.2). Now i have cloned a new instance and it runs on port 8050. Now i want to install and configure OC4J with it. I have done the OC4J Installation Successfully. Here i used the OC4J Version 9.0.3.I have changed the http-web-site.xml port number to 8890 and rmi.xml port to 23793 as per the document i got.To create the starting script, file name called .start_oc4j I issued cd $OC4J_TOP/j2ee/home/ then java -jar oc4j.jar andit throws the error[applpdev@oraapps ~]$ cd $OC4J_TOP[applpdev@oraapps home]$ pwd/pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/[applpdev@oraapps oc4j]$ cd j2ee/home/[applpdev@oraapps home]$ java -jar oc4j.jarError starting JMS-Server: Unable to bind socket: Address already in useError starting ORMI-Server. Unable to bind socket: Address already in use[applpdev@oraapps home]$

  • RELEVANCY SCORE 2.88

    DB:2.88:Socket Program Communicate Tandem Server 8d


    I am new to these socket programs. My program is doing communicates with the Tandem Server. Tandem Server Read the Client Request one port number and give the response another port number. Since my program using two socket binds, one bind sends the request using write method and second bind receive the response using read method. But I have facing Read Time Out Error. Can anybody tell me how to solve this problem?

    DB:2.88:Socket Program Communicate Tandem Server 8d

    I am using TCP/IP connection not UDPIn that case it is even less likely that two ports are being used.
    But I have facing same problem Read Time Out So the server didn't send anything to that port either.

    Or your timeout is too short. (It's specified in milliseconds, remember, not seconds for example.)

    Clearly you need the actual protocol specification. We've done enough guessing.

  • RELEVANCY SCORE 2.88

    DB:2.88:Question About "Java.Net.Serversocket.Accept()" 1j


    java.net.ServerSocket.accept() will listen to the specified port for some requests and create a socket.

    But some question bewilder me.

    There is a code :

    ServerSocket serverSocket = new ServerSocket(listenPort); // Create a server socket to listen to the sepcified port.
    while(true) { // Keep listening without break.
    Socket incomingConnection = serverSocket.accept();
    handleConnection(incomingConnection); // Handle the request with multi thread.
    }
    } catch (BindException e) {
    System.out.println("Unable to bind to port " + listenPort);
    } catch (IOException e) {
    System.out.println("Unable to instantiate a ServerSocket on port: " + listenPort);
    }The while {} block make the ServerSocket keep listening every time. If there is a request, the accept() method will create a socket and will not be block until a connection is made.

    But ,if there are more than one request at the same time? What will the accept() method process? Will it create sockets for each request at the same time?

  • RELEVANCY SCORE 2.87

    DB:2.87:Activemq-Broker Port Issue px



    Hi,

    I've couple of fuse (4.4) instance running on LINUX. When I start the second instance, it throws exception related to port binding issue for active-mq broker. Here's the exception.

    org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint container for bundle activemq-broker.xml

    org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean .component-2

    ..........

    Failed to bind to server socket: tcp://localhost:61616 due to: java.net.BindException: Address already in use

    I've made sure to modify activemq-broker.xml to change the port in my second instance. Here are the entries.

    Not sure why its still trying to bind to 61616 instead of 61617. Am I missing something here?

    Any help will be appreciated.

    - Thanks

    DB:2.87:Activemq-Broker Port Issue px


    L.S.,

    There's no auto-redeploy for the ActiveMQ configuration file and the configuration gets stored in the bundle cache.

    That's why, after updating the etc/activemq-broker.xml file on an existing container, you either have to remove the data directory and restart the container or do an explicit osgi:update on the bundle for the broker configuration file?

    Regards,

    Gert Vanthienen

  • RELEVANCY SCORE 2.86

    DB:2.86:Urgent : Fail To Setup The Weblogic 8.1 Cluster 3s



    I have two machines (Machine A and Machine B) both running weblogic 8.1 in Windows
    2000 environment.

    The IP address of Machine A and Machine B is 10.87.17.153 and 10.87.17.159 respectively.

    I need to make a cluster which is conposed of this two machine , one of the machine
    is acted as Administration Server.

    In machine A, I start the Weblogic server by using command 'startWebLogic'

    I already created a domain - 'mydomain' and create server instance - 'myServer'
    and additional two server instances 'myServer-1' and 'myServer-2' in Machine A

    The listen address of myServer-1 is localhost and port is 7001
    The listen address of myServer-2 is 10.87.17.159 and port is 10000

    Then I start the server instance of machine A by using command 'startManagedWebLogic
    myServer-1 http://localhost:7001'

    Then I start the remote server instance of machine A by using command 'startManagedWebLogic
    myServer-2 http://localhost:7001'

    Then I get this error

    Nov 27, 2003 11:58:08 AM GMT+08:00 Emergency WebLogicServer BEA-000350

    Unable to create a server socket on Channel Default for: 10.87.7.129, port: 1000
    0. java.net.BindException: Cannot assign requested address: JVM_Bind Perhaps the
    address 10.87.7.129 is incorrect or another process is using port 10000.
    Nov 27, 2003 11:58:08 AM GMT+08:00 Emergency Security BEA-090085 Server
    failed to bind to the configured port. The port may already be used by another
    process.
    Nov 27, 2003 11:58:09 AM GMT+08:00 Emergency WebLogicServer BEA-000342

    Unable to initialize the server: Server failed to bind to the requested port.
    Se
    e preceeding log message for details.
    ***************************************************************************
    The WebLogic Server did not start up properly.
    Exception raised: 'weblogic.server.ServerLifecycleException: Server failed to
    bi
    nd to the requested port. See preceeding log message for details.'
    Reason: Server failed to bind to the requested port. See preceeding log message
    for details.
    ***************************************************************************

    I also change the using other port for the setting of listend address of machine
    B, but still get the same error.

    Any one can help me to solve this problem... It's very urgent..
    Thanks!

    DB:2.86:Urgent : Fail To Setup The Weblogic 8.1 Cluster 3s


    I have two machines (Machine A and Machine B) both running weblogic 8.1 in Windows
    2000 environment.

    The IP address of Machine A and Machine B is 10.87.17.153 and 10.87.17.159 respectively.

    I need to make a cluster which is conposed of this two machine , one of the machine
    is acted as Administration Server.

    In machine A, I start the Weblogic server by using command 'startWebLogic'

    I already created a domain - 'mydomain' and create server instance - 'myServer'
    and additional two server instances 'myServer-1' and 'myServer-2' in Machine A

    The listen address of myServer-1 is localhost and port is 7001
    The listen address of myServer-2 is 10.87.17.159 and port is 10000

    Then I start the server instance of machine A by using command 'startManagedWebLogic
    myServer-1 http://localhost:7001'

    Then I start the remote server instance of machine A by using command 'startManagedWebLogic
    myServer-2 http://localhost:7001'

    Then I get this error

    Nov 27, 2003 11:58:08 AM GMT+08:00 Emergency WebLogicServer BEA-000350

    Unable to create a server socket on Channel Default for: 10.87.7.129, port: 1000
    0. java.net.BindException: Cannot assign requested address: JVM_Bind Perhaps the
    address 10.87.7.129 is incorrect or another process is using port 10000.
    Nov 27, 2003 11:58:08 AM GMT+08:00 Emergency Security BEA-090085 Server
    failed to bind to the configured port. The port may already be used by another
    process.
    Nov 27, 2003 11:58:09 AM GMT+08:00 Emergency WebLogicServer BEA-000342

    Unable to initialize the server: Server failed to bind to the requested port.
    Se
    e preceeding log message for details.
    ***************************************************************************
    The WebLogic Server did not start up properly.
    Exception raised: 'weblogic.server.ServerLifecycleException: Server failed to
    bi
    nd to the requested port. See preceeding log message for details.'
    Reason: Server failed to bind to the requested port. See preceeding log message
    for details.
    ***************************************************************************

    I also change the using other port for the setting of listend address of machine
    B, but still get the same error.

    Any one can help me to solve this problem... It's very urgent..
    Thanks!

  • RELEVANCY SCORE 2.86

    DB:2.86:Get Port Number Of The Client Socket Program sd


    Hi All,
    I am new to socket programming.I have a client and server socket program which communicates between them.I need to get the port number of the client program programmatically in the server socket program.The code for the server socket which i mentioned below uses a port number which has been hard coded.This value has to be dynamically get by the server socket program.
    Is there any sample codes or links that might be useful

    Server.java
    import java.net.*;
    import java.io.*;
    public class Server {
    public static void main(String[] ar) {
    /*This port number has to received by the server program*/ Now the port numbers are hard coded
    int port = 6666; /*// just a random port. make sure you enter something between 1025 and 65535.*/

    try {
    ServerSocket ss = new ServerSocket(port); // create a server socket and bind it to the above port number.
    System.out.println("Waiting for a client...");

    Socket socket = ss.accept(); // make the server listen for a connection, and let you know when it gets one.

    System.out.println("Got a client :) ... Finally, someone saw me through all the cover!");
    System.out.println();

    // Get the input and output streams of the socket, so that you can receive and send data to the client.
    InputStream sin = socket.getInputStream();
    OutputStream sout = socket.getOutputStream();

    // Just converting them to different streams, so that string handling becomes easier.
    DataInputStream in = new DataInputStream(sin);
    DataOutputStream out = new DataOutputStream(sout);
    String line = null;
    while(true) {
    line = in.readUTF(); // wait for the client to send a line of text.
    System.out.println("The client just sent me this line : " + line);
    System.out.println("I'm sending it back...");
    out.writeUTF(line); // send the same line back to the client.
    out.flush(); // flush the stream to ensure that the data reaches the other end.
    System.out.println("Waiting for the next line...");
    System.out.println();
    }
    } catch(Exception x) {
    x.printStackTrace();
    }
    }
    }

    DB:2.86:Get Port Number Of The Client Socket Program sd

    @marcel_hecker:
    The code for the server socket which i mentioned below uses a port number which has been hard coded.This value has to be dynamically get by the server socket program.The port he's looking for to make dynamic is the port made static in the code. If you look at said code, you see that the static port is only used in the ServerSocket constructor, that is, it is the port used for listening.

    This sort of contradicts your interpretation. Moreover, the example code he's showing does not require the client port at all. I don't know how much is similar and how much is different between that example and what he's trying to code, but it does give a generic assumeable regarding the intention of the question.

    Then again, I may be completely wrong about this, but since there isn't a second post from this person, I have to go by what information is available.

  • RELEVANCY SCORE 2.85

    DB:2.85:Socket Bind Fails In Vista p3


    I have developed a network client  program in XP using Visual C++ 6.0, it's running ok in XP, but when it's running in vista, it points out that socket bind error!
     
    The following is my network clinet program design: (omit some details)
     
    1. create send socket
    g_bcastSockfd = socket(AF_INET,  SOCK_DGRAM,  IPPROTO_UDP);//this socket is used for sending data
     
    sockaddr_in bindAddr;memset(bindAddr, 0, sizeof(SOCKADDR_IN));bindAddr.sin_family = AF_INET;bindAddr.sin_port = htons(17786);bindAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    bind(g_bcastSockfd, (SOCKADDR*)bindAddr, sizeof(SOCKADDR_IN));//using appointed port(17786) send data, not a temporary one
     
    BOOL val = 1;
    setsockopt(g_bcastSockfd, SOL_SOCKET, SO_BROADCAST, (char*)val, sizeof(BOOL));
     
     memset(g_bcastAddr, 0, sizeof(SOCKADDR_IN)); g_bcastAddr.sin_family = AF_INET; g_bcastAddr.sin_port = htons(PORT_SENDTO); g_bcastAddr.sin_addr.s_addr = inet_addr(255.255.255.255);
     
    sendto(g_bcastSockfd, msg, len, 0, (SOCKADDR*)g_bcastAddr, sizeof(SOCKADDR_IN));
     
     
    2. create receive socket
    sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
     
    setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (char*)val, sizeof(BOOL));
     
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)val, sizeof(BOOL));//set this option because i want to use port(17786) again later
     
    memset(local, 0, sizeof(SOCKADDR_IN));local.sin_family = AF_INET;local.sin_port = htons(17786);//receiving data uses the same port as sendinglocal.sin_addr.s_addr = htonl(INADDR_ANY);
     
    bind(sockfd, (SOCKADDR*)local, sizeof(SOCKADDR_IN));//bind error is occured here
     
    recvfrom(sockfd, ...);
     
    program runs, first, send data, then, wait for receiving from server...
     
    I have heard that vista does not support binding multiple sockets to the same address, is that right?

    DB:2.85:Socket Bind Fails In Vista p3


    Check this out:
     
    Windows Vista cannot obtain an IP address from certain routers or from certain non-Microsoft DHCP servershttp://support.microsoft.com/kb/928233
     


    You connect a Windows Vista-based computer to a network.


    A router or other device that is configured as a Dynamic Host Configuration Protocol (DHCP) server is configured on the network.


    The router or the other device does not support the DHCP BROADCAST flag.

  • RELEVANCY SCORE 2.85

    DB:2.85:Help: How To Bind A Tcp/Ip Socket ? x7



    I'm trying to use write a TPC/IP socket program. But i'm not to know how bind a socket . Here is the code:
    program WINSOCK
    use dfwin
    implicit none

    integer Err,Pcol,IP,Queue
    integer*2 wVer,port

    type(T_s_sockaddr_in) IpAddr
    type (T_WSADATA) WSinfo

    wVer=#101
    Err = WSAStartup (wVer,WSinfo)
    Pcol= socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)

    port=1250
    IpAddr.sin_family=AF_INET
    IpAddr.sin_port=htons(port)
    IpAddr.sin_Addr.s_addr=htonl(INADDR_ANY)

    Err= bind(Pcol,IpAddr,sizeof(IpAddr))

    Err= WSAGetLastError()
    print *,'Done'
    end program WINSOCK

    Some one can help me correct this binding socket,please ?
    Sorry for possible grammar and other mistakes.

    DB:2.85:Help: How To Bind A Tcp/Ip Socket ? x7


    Hi there,
    is there a way to establish a TCP IP connection between a fortran program with another program?

    Markus

  • RELEVANCY SCORE 2.85

    DB:2.85:Udp: How To Set The Outgoing Calling Port? dk


    How can I setup the LocalEndPoint before sending a conectionless UDP call ? I need to send a broadcast from a specific port.
     
    Documentation states:
    You are also not required to call the Bind method, because the underlying service provider will assign the most appropriate local network address and port number.
     
    dim Port as integer = 10010
    dim ReceiverAddress as System.Net.IPAddress= System.Net.IPAddress.Parse(172.31.255.255)
    Dim LocalEndPoint As System.Net.IPEndPoint = New System.Net.IPEndPoint(System.Net.IPAddress.Any, Port)
    [Socket].Bind(LocalEndPoint) ' error 
    Dim RemoteEndPoint As System.Net.IPEndPoint = New System.Net.IPEndPoint(ReceiverAddress, Port)
    [Socket].SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, True)
    ' socket flag must be 'none' not broadcast!!!
    [Socket].BeginSendTo(Data, 0, Data.Length, SocketFlags.None, RemoteEndPoint, AddressOf MyEndSendTo, Nothing)
     
    However, BIND gives me An invalid argument was supplied (error 10022). Without the bind, I can send broadcasts, however, I have no control over the local port number.
    thanks,
     
     

    DB:2.85:Udp: How To Set The Outgoing Calling Port? dk

    MSDN bind (Windows) http://msdn2.microsoft.com/en-us/library/ms737550.aspx    

    WSAEINVAL
    The socket is already bound to an address.
    So has bind already been called on the socket?  Or, more likely, already used for send or receive, which does an implicit bind.
     
    BTW that code works for me (of course creating a socket first).

  • RELEVANCY SCORE 2.85

    DB:2.85:Slow Socket Creation cz


    Hi all,

    I'm trying to connect to my smtp server with a socket but it takes several minutes to create the socket.

    Here is the code to reproduce my problem :

    public static void main(String[] args) {
    long start,duration;

    ProxySelector.setDefault(null);

    start = System.currentTimeMillis();
    Socket socket = new Socket(Proxy.NO_PROXY);
    duration = System.currentTimeMillis() - start;
    System.out.println("new Socket en " + duration+ "ms");

    // l'adresse IP de la cible
    start = System.currentTimeMillis();
    InetAddress ipAddr;
    try {
    ipAddr = InetAddress.getByName(CMain.SMTP_SERVER);

    duration = System.currentTimeMillis();
    // Socket de la cible
    start = System.currentTimeMillis();
    InetSocketAddress endPoint = new InetSocketAddress(ipAddr, 25);
    duration = System.currentTimeMillis() - start;
    System.out.println("endPoint en " + duration+ "ms");
    // Socket locale
    if (!socket.isBound()) {
    start = System.currentTimeMillis();
    socket.bind(null);
    duration = System.currentTimeMillis() - start;
    System.out.println("Bind en "+ duration + "ms");
    }
    System.out.println("Est-on connect? " + socket.isConnected());
    // Cration de la connexion
    start = System.currentTimeMillis();
    socket.connect(endPoint);
    duration = System.currentTimeMillis() - start;
    System.out.println("Connexion " + CMain.SMTP_SERVER + ": 25 en "+ duration + "ms");
    // Properties of the current socket
    System.out.println("Socket: " + socket);
    socket.close();
    } catch (UnknownHostException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }
    The output :

    new Socket en 189001ms
    endPoint en 0ms
    Bind en 0ms
    Est-on connect? false
    Connexion 127.0.0.1 : 25 en 0ms
    Socket: Socket[addr=localhost/127.0.0.1,port=25,localport=35106]Java version :
    java version "1.6.0_07"
    Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)My /etc/hosts file :
    127.0.0.1 localhost
    XX.XXX.XXX.XXX XXXXX

    # The following lines are desirable for IPv6 capable hosts
    XXXXXX ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhostsMy OS is debian 4.0.

    When I telnet my smtp server, the connection is immediate.

    Thanks you for any help

    DB:2.85:Slow Socket Creation cz

    No idea of what file I should configure on my server?

    I must have made something wrong but I don't know what?

    Thanks for any advice

  • RELEVANCY SCORE 2.84

    DB:2.84:Few Questions About Sockets In C# sc


    hey everyone,recently i've started learning about sockets and i have some questions:- what does the function Socket.Bind(EndPoint) do?- how can i change my clients Port? it seems to be random...- can i use two sockets on the same application? two sockets on the same port (server side)?- why cant i bind my server's socket to a different port? in order to do so i closed the socket created a new one and used the bind function on it with the new port...thanks in advance,dor.

    DB:2.84:Few Questions About Sockets In C# sc

    - what does the function Socket.Bind(EndPoint) do?   It associates a socket with a specific IP and port.- how can i change my clients Port? it seems to be random...   Use Bind method before Connect.- can i use two sockets on the same application? two sockets on the same port (server side)?   Only if you have two or more IP adresses. You can not use two sockets on same port and IP address.- why cant i bind my server's socket to a different port? in order to
    do so i closed the socket created a new one and used the bind function
    on it with the new port...   I think that you just can't bind socket again that is already used for comunication. everything is a matter of probability...

  • RELEVANCY SCORE 2.83

    DB:2.83:Re: Binding Two Outgoing Sockets To Same Local Port 98


    Do what you'd do in C:
    Socket s1 = new Socket(host, 12340, my_address, 20);

    Socket s2 = new Socket();
    s2.setReuseAddress(true);
    s2.bind(new InetSocketAddress(my_address, 20));
    s2.connect(new InetSocketAddress(host, 12341));

    DB:2.83:Re: Binding Two Outgoing Sockets To Same Local Port 98

    sjasja,

    This is the answer I needed. This works only apparently in JDK 1.4 and above. Maybe it was in 1.3...but I don't think so.

    So this fixes my issues for anyone running CrushFTP in MacOS X, Linux, Windows etc. Pretty much everywhere except OS 9, and that is OK.

    Thanks!

  • RELEVANCY SCORE 2.82

    DB:2.82:Re: Problem With Tcp Servent pz


    Don't bind the client-side socket to a port. Instead, allow the operating-system to choose a port and then call Socket.connect() to connect the client-side socket to the well-known port of your server.

    DB:2.82:Re: Problem With Tcp Servent pz

    Thanks for finally explaining.

    Personally I wouldn't expect to be able to use a port number that's already listening as an outbound port number on any system, although the TCP specification does permit it, so actually I'm surprised you found a platform where it works. And I'm even more surprised that it works on Windows and not Linux rather than the other way around, as Windows isn't exactly famous for its rigorous compliance with the TCP RFCs.

    Anyway it doesn't work. So basically you are outa luck ;-) You could try constructing a Socket() (no args), calling setReuseAddress(true), then binding and connecting it as separate steps (with bind() and connect(), but I don't promise it will work.

  • RELEVANCY SCORE 2.82

    DB:2.82:Rmi And Ssl -≫ A Big Problem!!! cd


    hi,
    i have built an application which communicate with applets over RMI. Now, I would like to encrypt the channel
    with SSL.

    constructor-call:
    ...
    super(0, new RMISSLClientSocketFactory(), new RMISSLServerSocketFactory());
    ...

    Client-Socket-class:

    public class RMISSLServerSocketFactory implements RMIServerSocketFactory, Serializable{
    public ServerSocket createServerSocket(int port) throws IOException{
    SSLServerSocketFactory fact = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    return fact.createServerSocket(port);
    }}

    Server-Socket-Class:
    public class RMISSLClientSocketFactory implements RMIClientSocketFactory, Serializable{
    public Socket createSocket(String host, int port) throws IOException{
    SSLSocketFactory fact = (SSLSocketFactory) SSLSocketFactory.getDefault();
    return fact.createSocket(host, port);
    }}

    Registry-binding:
    Naming.rebind("Server", svr)

    When I use this code, I can create the object instance.
    I can also bind it into the registry. However, it only waits a few seconds and then exits.

    when i bind the object in the rmiregistry as followed:
    ...
    Registry reg = LocateRegistry.createRegistry(1099);
    reg.rebind("Server", svr);
    ...

    the server runs without problems - but its not possible to connect the rmiregistry from client:
    ...
    Naming.lookup("//127.0.0.1:1099/Server");
    or
    Registry reg = LocateRegistry.getRegistry("127.0.0.1", 1099);
    reg.lookup("Server");
    ...

    the client/server throws no exception - the lookup-method doesnt work - why???
    i think the problem makes the ssl-sockets, but i'm not sure!!!

    (if i kill the server - ...connection refused to host 127.0.0.1....)

    whats the problem????????? - any idea

    mike

    DB:2.82:Rmi And Ssl -≫ A Big Problem!!! cd

    i dont understand the different between ...lookup of
    the service fails...and ...registry lookup fails... -
    is it the same??There's three things here (at least) that could fail.
    1. You have to connect to the remote host, which could fail.
    2. You have to find the registry, which could fail.
    3. You have to locate the service (Java class) you want, which could fail.

    i think the registry lookup fails. the client do
    nothing if i try to make a lookup to the registry with
    the followed line:

    interface xxx =
    (interface)naming.lookup("//127.0.0.1:1099/Server");Okay, you might check how you are formulating the URL. I've seen people have this problem many times. I'm not sure of the solution, but you need to search the forums for it. It has to do with HOW you build the URL. Maybe somebody else will post the solution, but it's the direction I'd go in if I was you.

    the client hangs-up in the lookup-line - i must abort
    the lookup. the server or client throws no exception.

    when i try to bind the server with:
    LocateRegistry.createRegistry(1099);
    naming.rebind("Server", svr);

    also it is not possible to bind the server to the
    rmiregistry - i must work with:
    ...
    Registry reg =
    = LocateRegistry.createRegistry(1099);
    reg.rebind("Server", svr);
    ...
    to bind the server to the registry!!- why?????
    if i work with this binding i try to make a lookup to
    the server with the ....naming.lookup(...); method
    which hangs-up.I'm confused, if you have a server, why would you need to bind it to a registry. I mean, it's a server! It doesn't need to bind to the registry.

    i tried to work with followed constructor-call:
    ...
    super();
    ...
    and the system works perfectly!! i think the problem
    makes the ssl-sockets, but i dont know.

    i were very happy to solve the problem.

    thanks mikeI'm not too sure about your problem. Also, some things you say are confusing, as English is probably not your first language. What I would do is find a tutorial or demo and get it working, then modify the code as needed. Sorry couldn't be of more help.

  • RELEVANCY SCORE 2.81

    DB:2.81:Problem With Winsock Recv Returning 0 Bytes Before Read Stream Is Emptied 81


     
    I have a WinSock application where the client connects to a server, sends a packet and waits for a response.   The server accepts the connection, receives the request, sends the response and closes the connection.  The sockets in both client and server are blocking.  When this application runs with the client and server on separate machines, the application works correctly.  When this application runs on the same machine, randomly the client's call to recv returns 0 bytes, and if I immediately call recv() again, recv() returns the expected data.  The failure is most frequent on Win2003 Server and less frequent on WinXP.  Win2000 has not shown the error.  I have recreated the failure using a simple test harness that uses this sequence of WinSock calls:
     
    Server: socket(AF_INET, SOCK_STREAM), bind(specific port, any address), listen(), accept()
    Client: socket(AF_INET, SOCK_STREAM), bind(any port, any address), connect(server address, port)
    Server: recv() - blocks until client sends data
    Client: send(500 byte packet)
    Server: recv() returns 500 bytes, send(500 byte packet), shutdown(), closesocket()
        - I have tried it with and without shutdown().  shutdown() reduces the frequency of the error but it does not eliminate it.
    Client: recv()
        - this will randomly return 0 bytes, but select() indicates data is waiting and another recv() succeeds.
     
    WinSock documention states that recv() should only return 0 when the server closes the connection after the data stream has been cleared.  Subsequent calls to recv() should return -1 and a WSAECONNRESET error.  I appears that the 0 byte packet from the closesocket() event is returned to the client out of sequence with the previously sent data from the server.
     
    So I am curious if this is expected behavior of WinSock and my work-around of using select() after the recv() returning 0 bytes out of sequence is correct.
     
    Thank You
     
     

    DB:2.81:Problem With Winsock Recv Returning 0 Bytes Before Read Stream Is Emptied 81

    Update on issue.This was determined to be an issue in the Windows 2003 tcpip.sys.  A knowledge base article is available with a hotfix.http://support.microsoft.com/kb/971383

  • RELEVANCY SCORE 2.81

    DB:2.81:Connection Services Starting On The Same Port Used By Other Services 1k


    In my Window OS, I have started the Tomcat on port. - 6565
    Then, configured the "jms" service on the same port (6565) in config.properties and started the Sun Message Queue Broker.

    Very strange, I did not got any error.
    Then I came to know it is because of "SO_REUSEADDR" option in the Server Socket.
    But, the MSDN says using the option "SO_REUSEADDR" is a security issue.

    http://msdn.microsoft.com/en-us/library/ms740621(VS.85).aspx

    As per the API specfication of java for ServerSocket.setReuseAddress (boolean)

    " Enable/disable the SO_REUSEADDR socket option.
    When a TCP connection is closed the connection may remain in a timeout state for a period of time after the connection is closed (typically known as the TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port. "

    But, I cannot see the behaviour as per the API.
    Regardless of the stae (LISTENING / TIME_WAIT / .....) of port, the new Server Socket is bind to the same port used by another service.

    Is the problem with Windows OS or the option "SO_REUSEADDR" should not be used ?

    DB:2.81:Connection Services Starting On The Same Port Used By Other Services 1k

    In my Window OS, I have started the Tomcat on port. - 6565
    Then, configured the "jms" service on the same port (6565) in config.properties and started the Sun Message Queue Broker.

    Very strange, I did not got any error.
    Then I came to know it is because of "SO_REUSEADDR" option in the Server Socket.
    But, the MSDN says using the option "SO_REUSEADDR" is a security issue.

    http://msdn.microsoft.com/en-us/library/ms740621(VS.85).aspx

    As per the API specfication of java for ServerSocket.setReuseAddress (boolean)

    " Enable/disable the SO_REUSEADDR socket option.
    When a TCP connection is closed the connection may remain in a timeout state for a period of time after the connection is closed (typically known as the TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port. "

    But, I cannot see the behaviour as per the API.
    Regardless of the stae (LISTENING / TIME_WAIT / .....) of port, the new Server Socket is bind to the same port used by another service.

    Is the problem with Windows OS or the option "SO_REUSEADDR" should not be used ?

  • RELEVANCY SCORE 2.81

    DB:2.81:Re: How To Specify A Local Port But It Should Not Be Bound 1j


    The question is a little unclear.

    Firstly, a socker server can know the client's ip address and connection port without the client specifying this in the Socket constructor. Read the java.net.Socket java doc for this info. The computer on which the client runs automagically assigns an available local port for your client connection -- so you shouldn't have to do that.

    If the question really means that my server can only connect to a single port on my client machine -- then either you must use that port and bind to it when transfering data. Or you should make a socket server on the client system to which the server can connect. The later would probably require a re-write of the code in the server which makes a connection to the client.

    DB:2.81:Re: How To Specify A Local Port But It Should Not Be Bound 1j


    there is a Server (Not a java program) that requires
    clients to connect to it using the following kind of
    connection below:

    a java client connects to the server with this socket
    constructorSocket ss = new Socket (remote ip, remote port, local ip, local port);This is your first problem. There is no such kind of server. The server will know the client's local port regardless of which Socket constructor the client uses, as someone else pointed out. Leave out the last two parameters.

    now the
    server sends responses to the local port specified in
    the constructor of the socket.or the local port assigned by the system if it wasn't specified, as it almost always shouldn't be.

    I need to create a listener on the localport
    so i can read the information sent in from the serverAHA!!!!!!! NO YOU DO NOT. You need to execute a read on the client socket. That's what it's for. It already represents an established connection between a client local port and the server.

    ..creating
    this ServerSocket ss = new ServerSocket
    (localport); in jave generates an "Address
    Already in Use Exception".As expected. It is.

    now what i asked was "how
    can i unbind the local port form the socket so java
    will not tell me it is already in use when creating a
    listener on it in ServerSocket".You don't want to do this as explained before. FYI you could close the Socket to release the port, but you will then discover that the server sends fail because it tries to send to the established connection.

    I hope this is clear now.Clear as mud. What is clear is that you do indeed need to read up on TCP/IP as recommended by several other posters. Your grasp is very slender.

  • RELEVANCY SCORE 2.80

    DB:2.80:Using Websocket Js In Windows 8.1 App. Where Is The Mistake? sf


    There is a script in php working with WebSocket, as he wrote himself at the time of writing there was no ready-made solutions

    initialization:
    $host = '192.168.10.225'; //host
    $port = '3994'; //port

    //Create TCP/IP sream socket
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    //reuseable port
    socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);

    //bind socket to specified host
    socket_bind($socket, 0, $port);

    //listen to port
    socket_listen($socket);
    And the client code (His warp over WebSocket):
    Socket.bind('open', function () {
    Socket.send({ name: 'alex', status: 'online' });
    });

    Socket.init(ws://192.168.10.225:3994/shell/rest.sock.php);
    ...
    var Socket = (function(){
    var socket;

    var self = {
    init: function(host){
    socket = new WebSocket(host);

    socket.onopen = function(e){ callEventList('open', e) };
    socket.onmessage = function(e){ callEventList('message', e) };
    socket.onclose = function(e){ callEventList('close', e) };
    },
    send: function (msg) {
    ...
    Works everywhere: chrome / opera / ie / android / ios
    But when trying to connect to the Windows store app js, produces an error:
    SCRIPT12029: WebSocket Error: Network Error 12029, Unable to communicate with the server
    Which is strange because The same code works ie
    Prompt where it may be a mistake to look for and where?

    Sorry for my eng...

    DB:2.80:Using Websocket Js In Windows 8.1 App. Where Is The Mistake? sf

    Hi,
    I tried to understand your code but then I recognized the code should be ok because it works with ie, Windows Store App use IE render engine.
    I guess the error could be thrown when the app network capability is not enabled, see this for more information:

    App capability declarations.
    Another possibility is you are trying to connect localhost which is not allowed in Windows Store App.
    --JamesTHE CONTENT IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED
    Thanks
    MSDN Community Support

    Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

  • RELEVANCY SCORE 2.80

    DB:2.80:Ssl Reading Problem In Server-Side 93


    Hi guys,
    I have a problem in my server implemetation with SSL Server Socket. I have created a server socket with a specfic port and bind address. Whenever a client connecfed, i grap its inputstream and starts to read as bytes. There is no problem to open server socket and certifacate authorization, and also a client successfully connects to server. But when client writes some data to its connected socket, server cannot read anything. Server throws no exception and there is no problem in writing. But the available bytes in inputstream is always 0. When i replace SSL socket with normal socket, everything is ok, server can read everything. I confused very much. since i have no concrete exception and stack trace, I know it is hard to explain and get help about my problem. I have added some parts from my code.
    Could you make any suggestions?

    Listening and connection part
    ServerSocketFactory socketFactory = SSLServerSocketFactory.getDefault();
    socket = socketFactory.createServerSocket(port,backLog,bindAddress);
    Socket clientSocket = socket.accept();
    in = new BufferedInputStream(clientSocket .getInputStream());Reading part

    while (continueRunning){
    try {
    Thread.sleep(1);
    if(in.available()1){
    System.err.println(in.available());
    continue;
    }

    MessageDecoder decoder= new MessageDecoder();
    Message msg = decoder.decode(in);
    if(msg == null){
    System.out.println("Decoded message is null");
    continue;
    }

    handler.messageReceived(msg);

    } catch (IOException e) {
    e.printStackTrace();
    continueRunning=false;
    try {
    clientSocket.close();
    } catch (IOException e1) {
    e1.printStackTrace();
    }
    } catch (InterruptedException e) {
    continueRunning=false;
    e.printStackTrace();
    try {
    clientSocket.close();
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }
    }
    }

    DB:2.80:Ssl Reading Problem In Server-Side 93

    OK but let me state again that SSLSocket.getInputStream().available() will never return anything except zero. The last poster in that thread is wrong about the timeout closing the socket: it doesn't.

  • RELEVANCY SCORE 2.80

    DB:2.80:The Web Proxy Filter Failed To Bind Its Socket To Ip_Address Port 443 j1


    We are using ISA 2006 to publish OWA based on Exchange 2007 everything was working fine from long time until users report that they can't access OWA from outside, I checked ISA server and found the following alert:
    The Web Proxy filter failed to bind its socket to 192.x.x.x port 443. This may have been caused by another service that is already using the same port or by a network adapter that is not functional. To resolve this issue, restart the Microsoft
    Firewall service.
    I restart Microsoft Service and everything worked fine for spesific time, then the issue occur again.
    I found KB888650 and confirm that we are using IP Address 192.x.x.x port 443 only for Exchange OWA
    Also in Application Event log I found the following warning:
    Event ID: 14148
    Description: The Web Proxy filter failed to bind its socket to 192.168.40.103 port 443. This may have been
    caused by another service that is already using the same portor
    by a network adapter that is not functional. To resolve this issue, restart the Microsoft Firewall service. The error code specified in the data area of the event properties indicates the cause of the failure.
    I follow KB925733 anddisable
    the Media Sensing feature for TCP/IP in Windows as suggested but still the same issue
    ThanksAbduljalil Abolzahab

    DB:2.80:The Web Proxy Filter Failed To Bind Its Socket To Ip_Address Port 443 j1

    Hi,

    Thank you for the post.

    You may edit the SocketsInAcceptReuseList registry value to prevent this issue:
    http://support.microsoft.com/kb/891992.

    Regards,Nick Gu - MSFT

  • RELEVANCY SCORE 2.80

    DB:2.80:Unable To Bind To Socket On Port 80 a7


    Hi,
    I am trying to create a server and client to send some basic messages back and forth. I started looking at the Socket Class provided by C# but I am unable to bind to port 80 (HTTP). It allows me to bind to other ports, but I get an exception for 80saying:
    Only one usage of each socket address (protocol / network address / port) is normally permitted.
    My browser is able to connect over port 80, I was thinking of using that port for my client/server communication.
    My question is that I can run different browsers and browser instancesat the same time. These browsers are clearly able to bind to port 80 concurrently to download web pages etc.. Why am I unable to bind?
    Thanks in advance.

    Dwight

    DB:2.80:Unable To Bind To Socket On Port 80 a7

    You cannot Bind to port 80 on your computer, the reason is pretty clear by the exeption you got that is already occupied/used by some other application. So you cant use it in your code, Its not a single occurance you run to Sockets and try to bind both 2 on same port, You'll see first will be ok and second will show you the same exception!
    Secondly, you are completly wrong in saying that your browser Binds to port 80 and view the webpages, Browers is only a client application which does not bind but get connected to port 80 on Some Webserver and retrieves and sends information back and forth! So your Webserver is using port 80 for incoming connection, Which is a server itself, You can connect to port 80 but not start a second Server on the same port!
    Solution is simple: Choose some port which is not used by some other application. There are already hundreds of reserved ports for windows and many other applications. Make a Random Guess and use some port in a Random number like 30923.
    I hope this clarifies your concept about connecting and binding, (Client/Server)
    Wish you best of luck for next!
    One Suggestion: Please try to post Networking related question on its appropriate forum so you get precise pointers on the solution of the problem!
    Best Regards,
    Rizwan

  • RELEVANCY SCORE 2.80

    DB:2.80:10gforms In Linux xm


    Hi,
    I install the 10gForms in a Linux Red Hat Advanced Server 3 without problems. I can connect by browser in port 7777 and 1810.

    After I make a "opmnctl stopall" and start again "opmnctl startall" I can't connect enymore to port 1810. I receive the error: "The connection was refused...."

    If I go to:
    ORACLE_HOME/opmn/logs
    and see the C4J~home~default_island~1 file I sse that error:
    "Error starting ORMI-Server. Unable to bind socket: Address already in use
    java.lang.NullPointerException
    at com.evermind.server.rmi.RMIServer.run(RMIServer.java:470)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.
    java:186)
    at java.lang.Thread.run(Thread.java:534)
    Oracle Application Server Containers for J2EE 10g (9.0.4.0.0) initialized
    "

    Can anyone help me?

    thanks

    Carlos

    DB:2.80:10gforms In Linux xm

    Hi,
    I install the 10gForms in a Linux Red Hat Advanced Server 3 without problems. I can connect by browser in port 7777 and 1810.

    After I make a "opmnctl stopall" and start again "opmnctl startall" I can't connect enymore to port 1810. I receive the error: "The connection was refused...."

    If I go to:
    ORACLE_HOME/opmn/logs
    and see the C4J~home~default_island~1 file I sse that error:
    "Error starting ORMI-Server. Unable to bind socket: Address already in use
    java.lang.NullPointerException
    at com.evermind.server.rmi.RMIServer.run(RMIServer.java:470)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.
    java:186)
    at java.lang.Thread.run(Thread.java:534)
    Oracle Application Server Containers for J2EE 10g (9.0.4.0.0) initialized
    "

    Can anyone help me?

    thanks

    Carlos

  • RELEVANCY SCORE 2.80

    DB:2.80:Wsock32.Lib - Bind() - Address Already In Use s3


    Hi,I've been trying to work on this assignment from home, without any success. I have a server that listens to a socket for a client request. At the university lab, I have no problems, however, at home, bind() keeps failing and the error I get from WSAGetLastError() is:
    WSAEADDRINUSE - Address already in use.

    DB:2.80:Wsock32.Lib - Bind() - Address Already In Use s3

     Pensador wrote:

     Andreas Masur wrote:

    First of all, did you use just 'netstat' or 'netstat -a'?

  • RELEVANCY SCORE 2.79

    DB:2.79:Bind Of Client Socket Throws Bind Exception 8m


    Hi everybody

    I already searched this forum for the bind exception, however I found no solution for this particular problem. On my XP platform I have an ethernet network interface and another one is created by a 3rd party bluetooth stack, that starts a dial up connection (over gprs).
    I want to make a TCP connection to a remote server. However for my tests, I have to force the Java client application to use the gprs network interface.

    Therefore I manually inquire the IP-Address of the gprs network interface with the ipconfig command in a cmd-shell.

    I pass this IP address as an argument (socket bind argument) to my Java Application and bind the client socket to this address (see the following code snippet). The bind method throws the Exception Address already in use: JVM_Bind. The netstat -a cmd doesnt neither list the gprs interface nor the port I used with the bind method. Anyway in my opinion the bluetooth stack only creates a network interface and does no further socket binding. I really dont understand the problem.

    start of code snippet
    -----
    Socket destinationSocket = new Socket();
    byte[] ipAddress = InetAddress.getByName(args[0]).getAddress();
    InetAddress inetAddress = InetAddress.getByAddress(ipAddress);
    InetSocketAddress bindpoint = new InetSocketAddress(inetAddress, 60000);
    destinationSocket.bind(bindpoint);
    destinationSocket.connect(destinationPort, 0);
    -----
    end of code snippet

    Any help would be very appreciated

    PS: how do you post your syntax highlighted code snippets in this forum? I get only a plain text editor after the forum login.

    Kind regards
    Hans-Joerg

    DB:2.79:Bind Of Client Socket Throws Bind Exception 8m

    You've got the ports the wrong way around. Zero is not a valid target port, and there is no need here to specify a bind port. Specify 0 as the bind port, so the system will choose a free one, and 60000 (or whatever the correct target port is) as the port to connect to.

  • RELEVANCY SCORE 2.79

    DB:2.79:Port Still Bind To A Socket Without Server Or Client jd


    Hi, forum people!

    I am experiencing problems with a client-server socket application.

    The client is a Java (1.3.0) program on a WinNT4 box.
    The server is a C program on a UNIX box.

    The problem is that when I have to restart the server, it often produce a BIND ERROR: Address already in useWhen I use netstat to search for the faulty socket, I obtain something like:
    Proto Recv-Q Send-Q Local Address Foreign Address (state)
    tcp 0 0 myServer.myService xxx.xxx.212.235.2742 FIN_WAIT_2The most surprising is that at this moment, neither server nor client on xxx.xxx.212.235 box are running! In fact, the only way I found to close this socket is to reboot the client box (eeeeekkkkkk - no good). Rebooting the server is unimaginable.

    The same client is also running on other OS (Solaris 2.5.1, HPUX 10.20, HPUX 11...) without such problems.

    Where should I search for the problem? On the server? But in this case why the FIN_WAIT_2 only occurs with sockets from NT4 box?

    Thanks in advance!

    Valere

    DB:2.79:Port Still Bind To A Socket Without Server Or Client jd

    Thanks guys for your contributions, it is very helpfull! Have to investigate into the client's code.

    Valere

  • RELEVANCY SCORE 2.78

    DB:2.78:How To Get Greater Log Detail From Mail.App In Lion (Slow Attachment Caching) cs


    I have an IMAP account, hosted by FuseMail, that is taking an extraordinary amount of time to catch attachments. I would say it is taking upwards of 10 minutes to cache one attachment. This is causing a side-effect in mail that it keeps spawning new threads for "Fetching new mail" which eventually makes Mail.app thread-bound and it stops responding (see image below of an example of what happened over night when I wasn't there to kill the treads).I would like to see a more detailed trascript of the connection with this IMAP server to see if the delay is with the server or with my client. However, I have been unable to capture what I'd like to see:If I use the Connection Doctor, turn off all other accounts and look at "Show Detail", I can see some log entries for READS and WRITES (FETCH and PEEK) but it's still difficult to see what's happening between those steps:WROTE Sep 17 12:47:39.874 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d787084.46 UID FETCH 7330 BODY.PEEK[2]4110304.16384WROTE Sep 17 12:47:46.098 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d34b57490DONEREAD Sep 17 12:47:46.101 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870* 6869 FETCH (UID 7330 BODY[2]4110304 {16384}READ Sep 17 12:47:46.150 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870Lvrf+t3/AIKHf8EyPgF/wUD/AGDPFX7BusaZ4f8Ag94JTT9Pj8Cahofh6ydfhzfaeFGnzWFqyCOGKONTavFAYGeynubdJYRLvX8gf2Nv2Iv+DgX9hD/gmj4O/YC/Z81n/glBpPjb----8X----snip----8X-----7aHwA/4Kf/sXfEv4P/Cn9tD4d6h4b1ZvD3jfQpP+EV+IV9o+rW91Y3Oo3enBb6GWOBZIJJNly08NtYW6G0WIzHoP2kP+CZP/AAU1/wCCruj6P8Ef+Cm/7TPwA/Zq/Y40/wDs2+1jwJ+zTLql3qnxREAD Sep 17 12:47:46.158 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d34b5749047.47 OK CompletedREAD Sep 17 12:47:46.195 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870O1RLACWTUtU1y3RLO0t9SiS8tbNLS6QpN5c7ST2ltfD9n/gp+yZ8G/2Q/gFqHwJ/Yi+GHwf/AGa9Jh09----8X----snip----8X-----hG4+MHwt1nxKNc0bwh5Uaahc2mlTaVFFJ4guZTc3Umoi9thJJcylI7W4Zb6L9Hv+CZ//AARa/YM/4JR6drd5+zD8P/EGqfFbV9POk678WROTE Sep 17 12:47:46.206 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d377d87f048.47 NOOPREAD Sep 17 12:47:46.216 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870QfFuojUvEWr2P2qS5W2LokdtaxBmiVo7OC3WYWlq04mkiSQfgD/wXk/4N6f+Ckn/AAVl/bzu/wBoz4a/E39iDwX8HNF8H6R4K8H2uua1r1nrMljAZryeS/SHTbmA----8X----snip----8X-----9qTxB8ULbwP8UNP+KPgD4UfDnxfqa+AoPEVna+XB4g1GK5t7eS51BJDEIxDHCESyVJZbuK4e2iPjX/wb0/toftvf8FvLD9v/APbt+Jv7MHj/APYv0zxglzpPgTSda1a+vl8K6WkjaLREAD Sep 17 12:47:46.285 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870pEmn6pps1j5VzPHby6nbJMIZWvdUaLY0y1+/3/AAVz/Yh8Vf8ABRz/AIJ1ftMfsa+BfHHh/wCHXjfxfp+nSaPqurW8----8X----snip----8X-----BYbWKS5uWhgh86QN+UH/AAXp/wCDfXUf+Cwfir4afGb4f/tIeH/gj8VvBng/VNBsNK1bwXa3lj4mmaQ3FnFcanb+XqNrEJREAD Sep 17 12:47:46.301 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870mkVzJ9viiWUyW9rFI119s6DwD/AMG3PwJ8afAnxr8Ov+Cjf7W37X//AAUy+LWs+H7zQNO8bfEHxbeP/wAK2868W4N74ZtLme6/sq7f7Npomllmu/O+weWQttcXNpL4B/wSW/4N----8X----snip----8X-----UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU)84.46 OK FETCH completed.WROTE Sep 17 12:47:46.322 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d333741d085.46 UID FETCH 7330 BODY.PEEK[2]4126688.16384READ Sep 17 12:47:46.412 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d377d87f048.47 OK CompletedWROTE Sep 17 12:47:46.434 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d345d787049.47 IDLEREAD Sep 17 12:47:46.579 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d345d7870+ idlingI just can't see enough to figure out if the problem is on my end or the FuseMail end. I have been looking around trying to figure out how to increase the debug level without much luck.I found this about the sqlite3 db but the Envelope file is not in the same place anymore:http://www.macworld.com/article/56673/2007/03/mailfix.htmlI also played around with the defaults but could not find anything specific to the connection/transfer/caching protocols:http://hints.macworld.com/article.php?story=2004101603285984I also tried the "Turn on Logging" Mail script:http://macs.about.com/od/usingyourmac/ss/Troubleshooting-Apple-Mail-Using-Apple- Mails-Troubleshooting-Tools_3.htmbut if it is turning anything on in the Console, I can't see it.Any suggestons?

    DB:2.78:How To Get Greater Log Detail From Mail.App In Lion (Slow Attachment Caching) cs

    I have an IMAP account, hosted by FuseMail, that is taking an extraordinary amount of time to catch attachments. I would say it is taking upwards of 10 minutes to cache one attachment. This is causing a side-effect in mail that it keeps spawning new threads for "Fetching new mail" which eventually makes Mail.app thread-bound and it stops responding (see image below of an example of what happened over night when I wasn't there to kill the treads).I would like to see a more detailed trascript of the connection with this IMAP server to see if the delay is with the server or with my client. However, I have been unable to capture what I'd like to see:If I use the Connection Doctor, turn off all other accounts and look at "Show Detail", I can see some log entries for READS and WRITES (FETCH and PEEK) but it's still difficult to see what's happening between those steps:WROTE Sep 17 12:47:39.874 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d787084.46 UID FETCH 7330 BODY.PEEK[2]4110304.16384WROTE Sep 17 12:47:46.098 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d34b57490DONEREAD Sep 17 12:47:46.101 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870* 6869 FETCH (UID 7330 BODY[2]4110304 {16384}READ Sep 17 12:47:46.150 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870Lvrf+t3/AIKHf8EyPgF/wUD/AGDPFX7BusaZ4f8Ag94JTT9Pj8Cahofh6ydfhzfaeFGnzWFqyCOGKONTavFAYGeynubdJYRLvX8gf2Nv2Iv+DgX9hD/gmj4O/YC/Z81n/glBpPjb----8X----snip----8X-----7aHwA/4Kf/sXfEv4P/Cn9tD4d6h4b1ZvD3jfQpP+EV+IV9o+rW91Y3Oo3enBb6GWOBZIJJNly08NtYW6G0WIzHoP2kP+CZP/AAU1/wCCruj6P8Ef+Cm/7TPwA/Zq/Y40/wDs2+1jwJ+zTLql3qnxREAD Sep 17 12:47:46.158 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d34b5749047.47 OK CompletedREAD Sep 17 12:47:46.195 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870O1RLACWTUtU1y3RLO0t9SiS8tbNLS6QpN5c7ST2ltfD9n/gp+yZ8G/2Q/gFqHwJ/Yi+GHwf/AGa9Jh09----8X----snip----8X-----hG4+MHwt1nxKNc0bwh5Uaahc2mlTaVFFJ4guZTc3Umoi9thJJcylI7W4Zb6L9Hv+CZ//AARa/YM/4JR6drd5+zD8P/EGqfFbV9POk678WROTE Sep 17 12:47:46.206 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d377d87f048.47 NOOPREAD Sep 17 12:47:46.216 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870QfFuojUvEWr2P2qS5W2LokdtaxBmiVo7OC3WYWlq04mkiSQfgD/wXk/4N6f+Ckn/AAVl/bzu/wBoz4a/E39iDwX8HNF8H6R4K8H2uua1r1nrMljAZryeS/SHTbmA----8X----snip----8X-----9qTxB8ULbwP8UNP+KPgD4UfDnxfqa+AoPEVna+XB4g1GK5t7eS51BJDEIxDHCESyVJZbuK4e2iPjX/wb0/toftvf8FvLD9v/APbt+Jv7MHj/APYv0zxglzpPgTSda1a+vl8K6WkjaLREAD Sep 17 12:47:46.285 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870pEmn6pps1j5VzPHby6nbJMIZWvdUaLY0y1+/3/AAVz/Yh8Vf8ABRz/AIJ1ftMfsa+BfHHh/wCHXjfxfp+nSaPqurW8----8X----snip----8X-----BYbWKS5uWhgh86QN+UH/AAXp/wCDfXUf+Cwfir4afGb4f/tIeH/gj8VvBng/VNBsNK1bwXa3lj4mmaQ3FnFcanb+XqNrEJREAD Sep 17 12:47:46.301 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d345d7870mkVzJ9viiWUyW9rFI119s6DwD/AMG3PwJ8afAnxr8Ov+Cjf7W37X//AAUy+LWs+H7zQNO8bfEHxbeP/wAK2868W4N74ZtLme6/sq7f7Npomllmu/O+weWQttcXNpL4B/wSW/4N----8X----snip----8X-----UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU)84.46 OK FETCH completed.WROTE Sep 17 12:47:46.322 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:imap.socialogue.com -- port:993 -- socket:0x7f8d32e16d30 -- thread:0x7f8d333741d085.46 UID FETCH 7330 BODY.PEEK[2]4126688.16384READ Sep 17 12:47:46.412 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d377d87f048.47 OK CompletedWROTE Sep 17 12:47:46.434 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d345d787049.47 IDLEREAD Sep 17 12:47:46.579 [kCFStreamSocketSecurityLevelNegotiatedSSL] -- host:mail.me.com -- port:993 -- socket:0x7f8d348b91a0 -- thread:0x7f8d345d7870+ idlingI just can't see enough to figure out if the problem is on my end or the FuseMail end. I have been looking around trying to figure out how to increase the debug level without much luck.I found this about the sqlite3 db but the Envelope file is not in the same place anymore:http://www.macworld.com/article/56673/2007/03/mailfix.htmlI also played around with the defaults but could not find anything specific to the connection/transfer/caching protocols:http://hints.macworld.com/article.php?story=2004101603285984I also tried the "Turn on Logging" Mail script:http://macs.about.com/od/usingyourmac/ss/Troubleshooting-Apple-Mail-Using-Apple- Mails-Troubleshooting-Tools_3.htmbut if it is turning anything on in the Console, I can't see it.Any suggestons?

  • RELEVANCY SCORE 2.78

    DB:2.78:Ethernet An Lwip sx



    i have no experience working with the EDK and embedded solutions, i am trying to implement a ethernet communication board ML605-PC but i have some difficults. I am using the xapp1026,but it doesnt work

    In the Raw mode i have the folowing error in the tcp_bind function:"Unable to bind the port 7" and if i set the debug options i have the message "tcp_slowtmr: no active pcbs", and the board dont communicate whit the PC.

    In the socket mode , i have an error related with the iperf server. i have the output:

    -----lwIP Socket Mode Demo Application ------Board IP: 192.168.1.10Netmask : 255.255.255.0Gateway : 192.168.1.1 Server Port Connect With..-------------------- ------ -------------------- echo server 7 $ telnet board_ip 7 rxperf server 5001 $ iperf -c board ip -i 5 -t 100 txperf client N/A $ iperf -s -i 5 -t 100 (on host with IP 192.168.1.100) tftp server 69 $ tftp -i 192.168.1.10 PUT source-file http server 80 Point your web browser to http://192.168.1.10auto-negotiated link speed: 100Connecting to iperf server...error in connect

    i create a new design using the ethernet Lite and the TMAC whit the default echo server but it still not working.

    Someone can help me to solve this problem.







    Solved!
    Go to Solution.

    DB:2.78:Ethernet An Lwip sx


    The attachement file is my enthernet demo upd, tx and rx from windows 7.










    Attachments:







    Demo_Enet.zip ‏7971 KB

  • RELEVANCY SCORE 2.78

    DB:2.78:Ip Address Camouflage 7j


    I want to using Java socket to achieve the concealment of original IP address, that means I want to using a new IP address to replace the old one, the function like the NAT. How can I do it ?
    I try to use Jpcap, I wounder if I should use the raw socket send this packet directly or still use the jave socket only bind the new local IP address.
    I found the Socket(InetAddress address, int port, InetAddress localAddr, int localPort) mthod can bind the random local IP address, however it report
    Exception in thread "main" java.net.BingException: cannot assign requested address: JVM_Bind
    I already set the localAddr, is there still something I need to modify?

    I also try to use Jpcap, but it said on windows I need to set the datalink header, I don't know how to do it?
    is there anyone can help me?
    Thanks in advance!

    DB:2.78:Ip Address Camouflage 7j

    Anyway, I config my adapter using two IP address now
    in windowsXP, so I can send the packet without error.
    However, I didn't understand the reason, could anybody
    can explain?If you've configured your machine as a multi homed host, aka router, you can bind to ports on any of those IPAdresses. Usually such a host has multiple ethernet cards in it. If WXP lets you configure a single adapter that way,then that will do.

    I also want to set this step using Java, should I
    modify the regedit or other places#65311;
    Thanks in advance!You should leave modifying the registry to windows programs, but if you must you will need to use some Windows C or C++ code to do it. Here's an example of some C++ code to write into the software hive in the registry. Its from an ActiveX component that I wrote before I knew any better so its littered with DCOM-VB interface crap, but it might point you in the right direction (or off the deep end :-))
    // write a value at currentuser\software\key\subkey
    // in the registry
    BOOL CPc328winCtrl::WriteToSoftwareHive(LPCTSTR key, LPCTSTR valuename, LPCTSTR value)
    {
    BOOL res;
    HKEY hkSoft;
    HKEY hkUser;
    long r;
    unsigned long t,len;

    t = REG_SZ;
    res = FALSE;
    r = RegOpenKey(HKEY_CURRENT_USER,"Software",hkSoft);
    if(ERROR_SUCCESS==r)
    {
    r = RegCreateKey(hkSoft,key,hkUser);
    if(ERROR_SUCCESS==r)
    {
    len = 1+strlen(value);
    r = RegSetValueEx(hkUser,valuename,NULL,t,(unsigned char *)value,len);// set the value
    res = (r == ERROR_SUCCESS);
    RegCloseKey(hkUser);
    }
    RegCloseKey(hkSoft);
    }
    return res;
    }You will need to access other parts of the registry, but its all the same, just different keys.

  • RELEVANCY SCORE 2.77

    DB:2.77:Cannot Bind Socket To Connection Port In Configured Port Range On System 8c


    Hi,I'm getting an error on the backup server "nsrmm: Cannot bind socket to connection port in configured port range on system bkup svr name". i also get an error "winworkr: Cannot bind socket to connection port in configured port range on system bkup svr name.Now I can connect to the server from another server on NMC. The server is w2k3 running NW731.Does anyone know how to resolve this?Tks,Liam

    DB:2.77:Cannot Bind Socket To Connection Port In Configured Port Range On System 8c

    From CLI you can run nsrports to see your current port settings. Since you have 7.3.1 (yuck) it is possible that connection ports are not limited, but perhaps you are using some older settings so you need to check that. To change it you can use also nsrports command.

  • RELEVANCY SCORE 2.77

    DB:2.77:I Can' T See The Start-Page x3


    Hi,

    I have installed WebLogic Server 5.1 on Solaris and it starts without any errors. But I can' t see anything on port 7001.

    The server-socket is listening, but i don't get any response over this port.
    I have also changed the port but it doesn' t help.
    thanks a lot,
    Florian

    DB:2.77:I Can' T See The Start-Page x3

    Hi,

    I have installed WebLogic Server 5.1 on Solaris and it starts without any errors. But I can' t see anything on port 7001.

    The server-socket is listening, but i don't get any response over this port.
    I have also changed the port but it doesn' t help.
    thanks a lot,
    Florian

  • RELEVANCY SCORE 2.77

    DB:2.77:Virtual Center Coexisting With Other Software On Server? a3


    Nooo, we can't have that in the 21st century ...

    For some reason the developer of this part of Virtual Center decided to listen (bind the used socket) on every available interface and IP on the server where VC is installed. Since it always uses port 80 this makes it impossible to have it coexist with other server software that actually can bind to a specific adress but wants to use that port.

    Through an SR I found out that that is just the way it is so here is an attempt to force a change by public ridicule.

    How can someone even consider writing a networking server without that feature? Especially since it takes all of five minutes to implement.

    DB:2.77:Virtual Center Coexisting With Other Software On Server? a3

    If I change the VC listening port, I have to specify when I connect with VCclient (Ex: server1.example.com:444).

    I did't try a redirect, this is my next step. I let you now the result!

  • RELEVANCY SCORE 2.77

    DB:2.77:Cant Bind A Udp Socket To A Port df



    using System;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    int port = 11000;
    Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
    IPEndPoint ipendpoint = new IPEndPoint(IPAddress.Any, port);

    try
    {
    socket.Bind(ipendpoint);
    Console.WriteLine(Successfully bound to port + port);
    }
    catch (SocketException e)
    {
    Console.WriteLine(Winsock error: + e.ErrorCode.ToString() + , + e.Message.ToString());
    }

    Console.Read();
    }
    }
    }

    DB:2.77:Cant Bind A Udp Socket To A Port df

    [SOLVED]
    Installed Windows 7 Ultimate, problem was solved.

  • RELEVANCY SCORE 2.77

    DB:2.77:Socket Api In 6.5 Beta kj



    Hello,

    I am working with 6.5 Beta with Host OS as Vista and Guest OS as XP. I am creating a communication application between guest and Host using the socket API, but I am unable to communicate. Is there any sample for that ?

    I create the server socket with VMADDR_CID_ANY as cid and VMADDR_PORT_ANY as port for the server address and bind the socket. After binding, I get the address and port using the getsockname and use the cid and port returned by the function for client connection. I am using Datagram for the connection between host and guest (Host is the server and guest is the client)

    Can you please help?

    All host functions ( getsockname, bind, socket) does not return -1 and the client functions too (socket and sendto) does not return -1.

    Can I use WSAAsynSelect of Winsock to notify FD_READ message for the socket?

    Thanks and Regards

    Ram

    DB:2.77:Socket Api In 6.5 Beta kj


    One other thing you might want to verify is that the virtual machine is configured to allow communication with other VMs and the host. This can be set in the Workstation UI by editing the VM Settings, selecting the Options tab, then choosing the Guest Isolation option. There is a check box there that you'll want to check.

  • RELEVANCY SCORE 2.77

    DB:2.77:Small Question About The Port Associated To A Socket 3d


    Hello.
    I have a question about the port associated to a socket. In the Java Tutorial, they say:

    "If everything goes well, the server accepts the connection. Upon acceptance, the server gets a new socket bound to a different port. It needs a new socket (and consequently a different port number) so that it can continue to listen to the original socket for connection requests while tending to the needs of the connected client."
    (http://java.sun.com/docs/books/tutorial/networking/sockets/definition.html)
    I perfectly agree.

    Now the problem appears. The followong code is supposed to list the ports:

    ServerSocket serverSocket = new ServerSocket(4444);
    Socket clientSocket = serverSocket.accept();
    int port = clientSocket.getPort();
    int localPort = clientSocket.getLocalPort();
    System.out.println("port=" + port + "; localport=" + localPort);

    I was expecting the local port to be different from 4444, since that is the port on wich the server still listens for other requests. But the output is something like this:

    port=1083; localport=4444

    Why is the local port still 4444? Maybe I missunderstood the facts and clientSocket is in fact the socket on the client's machine. But if so, how can I get the port on the server, the one it is spoken about here: "Upon acceptance, the server gets a new socket bound to a different port."?

    Best regards and many thanks in advance,
    rrainn.

    DB:2.77:Small Question About The Port Associated To A Socket 3d

    Thanx a lot for your answers. This has cleared things out for me. That was the only thing I didn't expect (the tutorial beeing wrong). :)

  • RELEVANCY SCORE 2.77

    DB:2.77:Tcp Socket Connect Error After Bind On Solaris Os 3k


    Hi All,

    I am trying to "connect" to our Tcp Server program from our client code, after "binding" the port of client socket. It is our requirement to fix same port of connect socket. So we use

    int on = 1;
    setsockopt(sk,SOL_SOCKET,SO_REUSEADDR, on, sizeof(on));

    before connet().

    But if we kill and restart the client program again, we get connect error.

    "connect error!: Address already in use"

    We check the the TCP socket status by netstat. It is showing that when we kill client program, that tcp socket goes to TIME_WAIT state, but does not return to ESTABLISHED, immediately if we restart client socket. We know, normarly TIME_WAIT state will be for 2MSL, and that's why we use SO_REUSEADDR. Seems then SO_REUSEADDR does not work properly.

    But same code we tested in Linux kernel 2.6, and working fine.

    Any insights is much appreciated

    Bye

    DB:2.77:Tcp Socket Connect Error After Bind On Solaris Os 3k

    Hi All,

    I am trying to "connect" to our Tcp Server program from our client code, after "binding" the port of client socket. It is our requirement to fix same port of connect socket. So we use

    int on = 1;
    setsockopt(sk,SOL_SOCKET,SO_REUSEADDR, on, sizeof(on));

    before connet().

    But if we kill and restart the client program again, we get connect error.

    "connect error!: Address already in use"

    We check the the TCP socket status by netstat. It is showing that when we kill client program, that tcp socket goes to TIME_WAIT state, but does not return to ESTABLISHED, immediately if we restart client socket. We know, normarly TIME_WAIT state will be for 2MSL, and that's why we use SO_REUSEADDR. Seems then SO_REUSEADDR does not work properly.

    But same code we tested in Linux kernel 2.6, and working fine.

    Any insights is much appreciated

    Bye

  • RELEVANCY SCORE 2.77

    DB:2.77:Inability To Control Initial Timeout In Socket Factory 7f


    Hello,

    We have built our own RMI socket factory where we want to control the timeout of the sockets created there. This is our code
    public Socket createSocket(String host, int port) throws IOException {
    Socket socket = new Socket(host, port);
    socket.setSoTimeout(requestTimeout);
    return socket;
    }Due to spurious heavy loads on our server, we need to operate with timeout values up to 100 seconds.
    However, we find that it is impossible to control the initial socket creation timeout. We observe this thought the lack of giving the the desired timeout parameter. Thus, the socket times out in the default 10 seconds in this initial call, not waiting the desired 100s before making the exception.

    Creating the socket through first creating a default socket and afterwards binding it like this
    Socket socket = new Socket();
    socket.setSoTimeout(socketTimout);
    socket.bind(new InetAddress(host,port));did not seem to do the trick in this setting either (neither did replacing bind with connect).

    What is the reason for this shortcoming in the API? Any workarounds?

    Best regards,
    Helge Fredriksen

    DB:2.77:Inability To Control Initial Timeout In Socket Factory 7f

    It's not a protocol issue if that's what you mean, it's just the way connect() is coded.

  • RELEVANCY SCORE 2.76

    DB:2.76:Client Socket Local Port 8z


     
    Hi to all,
    I need to make a connection using socket. For this I used tcpClient and connect to the server and port that the client told me, but for security reason, the client wants that I use a specific local port for this connection.
    In later C++ (C++ Builder) version I did that using ClientSocket and an Event called ClientLookup), that fired when the cliet try to connect to server, then I can specify the local port that I want to use, using sockaddr_in struct and the bind function  in the socket.
    In C#, are there any way that I can do this?
     
    Thanks in advance.

    DB:2.76:Client Socket Local Port 8z

     
    :-s
    Sorry, Alan, was my mistake.
    I appreciate your help, and sorry ... I was a 'little' confused

  • RELEVANCY SCORE 2.76

    DB:2.76:Re: Comm Suite 7 On Linux, Mta Server Not Starting, Cant Bind To Port 25 kz


    That error message does not look like it is about port 25. If it was port 25, then the previous answer -- that something else (like sendmail, perhaps) already has port 25 -- would be the right answer.

    That looks like it cannot open and bind the UNIX domain socket which the dispatcher uses to communicate with its worker processes. You could prove this by using the (linux equivalent of) truss to see what happens when does those calls. Try to "truss" just the command: "imsimta start dispatcher".

    DB:2.76:Re: Comm Suite 7 On Linux, Mta Server Not Starting, Cant Bind To Port 25 kz

    I am using a shared appliance, so I did not actually build that machine myself and I don't know how it's different from the standard RHEL5.3 build.
    It was missing some compatibility libraries, which a quick yum install fixed.

    However, I know I did not mess with the permissions in the /opt/sun/comms/messaging folder, or any other Comms Suite related directories.
    I admit that I am not a Unix permissions expert, but the only thing I can think of is that maybe permission inheritance from /opt played a role here?
    You mention the installer should explicitly set the permissions, I did not personally touch them and nobody else was accessing the server.
    I'll keep an eye on it during the next install and will report back on my findings.

    Nevertheless, it's running perfectly now.

  • RELEVANCY SCORE 2.76

    DB:2.76:Multicast And Broadcast Comm. 8j


    Hi all,
    here is my issue : I have a server sending messages (via UDP) on the network. I have multiple client reading these. To do this I have ti use java socket and I have 2 solutions :

    - use Socket and send/read DatagramSocket : the problem is I can't have multiple client reading the same port number on the same computer : socket aloready bind exeption
    - use MulticastSocket : Several clients can now read the same port number from the same computer but if I am disconnected from the network, I have a SocketException (error setting options).

    I user j2sdk 1.4.2 under win XP...

    Thanks for help !

    DB:2.76:Multicast And Broadcast Comm. 8j

    hello,

    i have got the same problem: java.net.SocketException: error setting options while my network is disconnect. What exaclty do you mean with "ex. reconntect"

  • RELEVANCY SCORE 2.76

    DB:2.76:Setsockopt So_Reuseaddr Successful But Bind Fails For Release Version Not For Debug. 77


    I have been facing a problem with UDP socket programming.
    I have to reuse port number for two different IP address. I am actually using SO_REUSEADD.
    I have no problem with debug version but with release version the bind is
    failing for 2nd IP address with the error code 10048. It's the error code for
    WSAEADDRINUSE. I am trying to with WinXP machine using Visual C++ 6.0.

    The application which we are using needs to connect to
    Primary and Backup server. The UDP connection should be established with both
    Primary and Backup server so that if the Primary server goes down, the client
    can still communicate with backup server and retrieves all information.

    I can’t use different port for both Primary and Backup serer as we are allowing
    multiple clients on a PC. Also we are not handling this on the server side
    since it’s a redundant system.

    Primary Server (Listening Port : 6000)
    Backup Server (Listen on 6000)

    Client1 (Listening
    Port 6003: Local Port:
    6002 so that the server knows it should send it to 6003, just add one and send the
    response back)

    Client2 (Listening
    Port 6005: Local Port:
    6002 so that the server knows it should send it to 6003, just add one and send the
    response back)

     

    I have a mechanism to select both listening and local port
    on the client. I bind with the specific portnumber and close the socket after
    identifying the port numbers.

    The setsockopt is successful for SO_REUSEADDR but bind fails for backup server.
    It’s strange that this issue never happens in debug version but release version
    fails to bind for the backup server.

    Here is the code to handle this scenario.

     

    WSADATA WsaData;
    int err = WSAStartup(MAKEWORD(1,1), WsaData);
    if ( err != 0 )
    {
    return (kOpenInvalidDev);
    }
    if ((mSocket = socket(PF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET)
    {
    return (kOpenDevError);
    }
    int optval;
    if(!mIsServer)
    {
    if (setsockopt(mSocket, SOL_SOCKET, SO_REUSEADDR, (char *) optval,
    sizeof (optval)) == SOCKET_ERROR)
    {
    close(); // close.
    return (kOpenDevError);
    }
    }
    if (setsockopt(mSocket, SOL_SOCKET, SO_BROADCAST, (char *) optval,
    sizeof (optval)) == SOCKET_ERROR)
    {
    close(); // close.
    return (kOpenDevError);
    }
    else if (mLocalAddr.sin_port != 0)
    {
    if (bind(mSocket, (struct sockaddr*)mLocalAddr, sizeof(mLocalAddr)) ==
    SOCKET_ERROR)
    {
    return (kOpenDevBusy);
    }
    }
    }

    DB:2.76:Setsockopt So_Reuseaddr Successful But Bind Fails For Release Version Not For Debug. 77

    The issue has been resolved. The issue was with project setting for release version. Setting the optimization value as default solves the problem. Thanks for the support.

  • RELEVANCY SCORE 2.76

    DB:2.76:How Do I Listen On A Random Port Using Java Nio? ax


    the only way nio would work (or at least the only way i know) is to BIND a n inet socket address to the serverSocket channel.

    inetaddress doesnt provide a random port number method.

    i tried doing

    ServerSocketChannel serverChannel = ServerSocketChannel.open();
    serverSocket = serverChannel.socket();
    serverSocket=new ServerSocket(0);

    but it doesnt work. must i create a brand new serversocket, find its port number, null it so it doesnt still bind to the port then create an inet socketadress on that port?

    DB:2.76:How Do I Listen On A Random Port Using Java Nio? ax

    oops. sorry, i did it by putting the try block in a while loop. should have thought of it earlier. my bad.

  • RELEVANCY SCORE 2.76

    DB:2.76:Linux Epo Agent - Cma Log - Trying To Start Http Server Thread - Failed To Bind Socket - Failed To Start Listen Server dm



    Hi,

    I noted that this doesnt appear to be listed anywhere when trying to search, so I thought I would post this just in case it helps anybody in the future. Agent log after an install showed the following every 20 seconds:

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Trying to start http server thread 164411320

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Started http server thread. Thread object is -186601072

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to bind socket. Error number 98

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to open socket

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to start server

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Failed to start listen server, will retry in 20 seconds

    As the only port I would suspect the agent to try to listen to was 8081/tcp I was guessing that the port was in use. This could be shown as below. The first of the below shows the output from a system where these errors do not occur, and the second shows output from the system that was seeing the above errors in /opt/McAfee/cma/scratch/etc/log:

    System without the issue:

    (host)#netstat tupln | grep 8081

    tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 6870/cma

    System with the issue:

    (host)#netstat tupln | grep 8081

    tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 16086/java

    On the second host we can see that the java process is already listening on port 8081, therefore the ePO agent software cannot bind to this port. A linux admin asked if this would be an issue on further boots (ie would the agent kick in first, and stop the java process from listening on this port, potentially killing something else). I advised that the default run level and appropriate rc directories (or files, depending on specific OS) would need to be checked to confirm. Another alternative would be to try to make java use a different port, but that would involve further investigation with regards to why it is actually using this port.

    Hope this helps somebody in the future!

    DB:2.76:Linux Epo Agent - Cma Log - Trying To Start Http Server Thread - Failed To Bind Socket - Failed To Start Listen Server dm


    Hi,

    I noted that this doesnt appear to be listed anywhere when trying to search, so I thought I would post this just in case it helps anybody in the future. Agent log after an install showed the following every 20 seconds:

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Trying to start http server thread 164411320

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Started http server thread. Thread object is -186601072

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to bind socket. Error number 98

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to open socket

    2013-02-05 11:38:44 [31634] [ListenServer] [E] Failed to start server

    2013-02-05 11:38:44 [9482] [ListenServer] [I] Failed to start listen server, will retry in 20 seconds

    As the only port I would suspect the agent to try to listen to was 8081/tcp I was guessing that the port was in use. This could be shown as below. The first of the below shows the output from a system where these errors do not occur, and the second shows output from the system that was seeing the above errors in /opt/McAfee/cma/scratch/etc/log:

    System without the issue:

    (host)#netstat tupln | grep 8081

    tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 6870/cma

    System with the issue:

    (host)#netstat tupln | grep 8081

    tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 16086/java

    On the second host we can see that the java process is already listening on port 8081, therefore the ePO agent software cannot bind to this port. A linux admin asked if this would be an issue on further boots (ie would the agent kick in first, and stop the java process from listening on this port, potentially killing something else). I advised that the default run level and appropriate rc directories (or files, depending on specific OS) would need to be checked to confirm. Another alternative would be to try to make java use a different port, but that would involve further investigation with regards to why it is actually using this port.

    Hope this helps somebody in the future!

  • RELEVANCY SCORE 2.75

    DB:2.75:Re: Socket Problem 8f


    Why wouldn't I need to state the local port number?
    My firewall will block any attempts to use a port I
    haven't specifically said I'm going to use, so how
    else would I guarantee the data would get through?
    Surely it's possible to define even if the way I've
    tried to do it isn't the right way...Firewalls usually are set up to block based on the destination port not the sending port. So if your server socket is on port 10001 (for example) then having that port open is enough. Even if the outgoing (client) port was 45876 it will get through.

    Yes it is possible to use but not like this. You can't have more than binding per port per machine. You would have to generate a new unbound port for each client socket you want to create.

    Specifiying the outgoing port and host in the client Socket is there more for being able to specify the outgoing address I would say. So this way you can bind the socket to the right outgoing address.

    I would test out your firewall assumptions first. You cannot bind the same port over and over so if you are going to have to specify the outgoing port it's going to be a headache for a number of reasons. I suspect you will find that opening the ServerSocket port itself will be all that you need to do.

    DB:2.75:Re: Socket Problem 8f

    As for what you're saying about having a server listening on a well known port, I've had that all along, hence me separating between client and server in what I said. I don't want the client to be forced into using a specific port, the server will use whatever port it damned well wants as well, but once it's set, it cannot change (each client gets a file containing information about the server such as its address and port when they want to use the service).

    As for the other problem I noticed I didn't actually start the thread to accept incoming connections on the ServerSocket which might be the problem, it certainly seems to have fixed it for now. Yes the send method flushes the stream before returning, bit odd it let me send data without the connection being actually accepted, but I suppose it might have all gone in the TCP buffer..

  • RELEVANCY SCORE 2.75

    DB:2.75:Why Does The Connect Function Return Nonzero? xa


    why does the following code run succsessful in vc6.0,but fail in vs2010?
    The code,which was compiled and linked in vc6.0,can run without problem.It can display successful connection.
    however,being compiled and linked in vs2010,the program always displays connection failure,why,please help me,thank you very much.
    //client
    void CMyDlg::OnBnClickedOk()
    {
    UpdateData(TRUE);
    if(m_addr.IsEmpty())
    {
    MessageBox(_T(please input ip));
    return;
    }
    server=socket(AF_INET,SOCK_STREAM,0);
    serveraddr.sin_family=AF_INET;
    serveraddr.sin_addr.S_un.S_addr=inet_addr ((char *)m_addr.LockBuffer());
    serveraddr.sin_port=htons(port);
    if(connect(server,(SOCKADDR *)serveraddr,sizeof(serveraddr)))
    {
    MessageBox(_T(连接失败));
    GetDlgItem(IDC_STATIC)-SetWindowText(_T(connection failure));
    Sleep(1000);
    GetDlgItem(IDC_STATIC)-SetWindowText(_T(no connection));
    return;
    }
    else
    {
    GetDlgItem(IDC_STATIC)-SetWindowText(_T(successful connection));
    }

    }
    //server
    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
    WSAData wsadata;
    WORD ver=MAKEWORD(2,2);
    WSAStartup(ver,wsadata);
    SOCKET server=socket(AF_INET,SOCK_STREAM,0);
    SOCKADDR_IN serveraddr;
    serveraddr.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
    serveraddr.sin_family=AF_INET;
    serveraddr.sin_port=htons(12345);
    bind(server,(SOCKADDR*)serveraddr,sizeof(serveraddr));
    listen(server,10);
    SOCKET client;
    while(true)
    {
    client=accept(server,0,0);
    }
    return 0;
    }

    DB:2.75:Why Does The Connect Function Return Nonzero? xa

    Only adding two sentence can solve this problem.
    if((client=accept(server,0,0))!=INVALID_SOCKET)
    {
    if((send(client,Password,sizeof(Password),0))!=SOCKET_ERROR)
    {
    coutwaiting for inputing password!\n;
    }
    ag: if(recv(client,Buff,sizeof(Buff),0)!=SOCKET_ERROR)
    {
    if(strcmp(Buff,123)==0)
    {
    coutcorrect password\n;
    send(client,TRUE,sizeof(TRUE),0);
    }
    else
    {
    coutwrong password\n;
    send(client,FALSE,sizeof(FALSE),0);
    goto ag;

    }

  • RELEVANCY SCORE 2.75

    DB:2.75:Sqlfire Not Starting On -Client-Bind-Address ps



    Hello all,

    I'm starting my SQLFire instance the following command ...

    /opt/sqlfire/bin/sqlf server start -dir=/opt/sqlfire/server1 -client-bind-address:10.10.10.111 -client-port=1527

    Yet SQLFire is still starting and binding to localhost ...

    Starting SQLFire Server using multicast for peer discovery: 239.192.81.1[10334]

    DB:2.75:Sqlfire Not Starting On -Client-Bind-Address ps


    In any case the start command should have complained about the unknown argument. I have already checked in a fix for that in development code, so now such unknown arguments will throw an IllegalArgumentException.

    thanks

    sumedh

  • RELEVANCY SCORE 2.74

    DB:2.74:Little Winsock Information Required In C++ c9


    Hi I did some network programming in .net and i have started in C== i have got my project up and running but i need a little bit of information about the host . currently i know how to establish a connection , send ,receive, ,file transfer etc. the simple code which i have created is: //Winsock Startup WSADATA ws; WSAStartup(0x0202,ws); //DEFINE THE SERVER - Control Panel PARAMETERS ControlPanel_mystruct.sin_family = AF_INET; ControlPanel_mystruct.sin_port =  htons(5050); //Port Address ControlPanel_mystruct.sin_addr.s_addr = inet_addr(IP_Control_Panel); //Internet Address //SOCKET FUNCTION GET NEW SOCKET DESCRIPTOR - RETURN HANDLE TO SERVER myclient[0] = socket(AF_INET,SOCK_STREAM,0); //Establish Connection if (connect(myclient[0],(struct sockaddr*) ControlPanel_mystruct,sizeof(ControlPanel_mystruct))!= -1)   //Blocking Function         {         cout Connection Esablished         } Anyways as you can see In my server code I know that I am suppose to bind to a port but i am not doing that still my program works. could you tell me what are my losses , if i dont bind and what its importance it.Furthermore how can i obtain the different ip address of the host. i was wandering if anyone could explain a quick gethostbyname and its usage to obtain ipaddress. thanks A candle loses nothing by lighting another candle.

    DB:2.74:Little Winsock Information Required In C++ c9

    Hi I did some network programming in .net and i have started in C== i have got my project up and running but i need a little bit of information about the host . currently i know how to establish a connection , send ,receive, ,file transfer etc. the simple code which i have created is: //Winsock Startup WSADATA ws; WSAStartup(0x0202,ws); //DEFINE THE SERVER - Control Panel PARAMETERS ControlPanel_mystruct.sin_family = AF_INET; ControlPanel_mystruct.sin_port =  htons(5050); //Port Address ControlPanel_mystruct.sin_addr.s_addr = inet_addr(IP_Control_Panel); //Internet Address //SOCKET FUNCTION GET NEW SOCKET DESCRIPTOR - RETURN HANDLE TO SERVER myclient[0] = socket(AF_INET,SOCK_STREAM,0); //Establish Connection if (connect(myclient[0],(struct sockaddr*) ControlPanel_mystruct,sizeof(ControlPanel_mystruct))!= -1)   //Blocking Function         {         cout Connection Esablished         } Anyways as you can see In my server code I know that I am suppose to bind to a port but i am not doing that still my program works. could you tell me what are my losses , if i dont bind and what its importance it.Furthermore how can i obtain the different ip address of the host. i was wandering if anyone could explain a quick gethostbyname and its usage to obtain ipaddress. thanks A candle loses nothing by lighting another candle.

  • RELEVANCY SCORE 2.74

    DB:2.74:Starting Byteman Without Listening On Port For Commands sc



    Hi,

    Is it possible to include byteman as a javaagent, without it listening on any port for commands?

    My current use case is;

    I have a java process that forks multiple child java processes.

    I can define command line arguments that are passed to the child processes, but the arguments are identical for each child process.

    I want to inject an identical byteman script into each process, which i can do via the javaagent parameters.

    When the child processes start, the first process to start binds to the default port that byteman uses, 9091, but all other child processes can not bind to that port (i see a "TransformListener() : unexpected exception opening server socket java.net.BindException: Address already in use" exception)

    I can not define the :port command line argument, as the same argument is used to fork each child process.

    Is it possible to start byteman without it binding to any port?

    Thanks in advance

    John

    DB:2.74:Starting Byteman Without Listening On Port For Commands sc


    ok, so i found the javaagent parameter;

    listener:false

    This gives me what I wanted

  • RELEVANCY SCORE 2.74

    DB:2.74:Stale Server Socket Reference fx


    i create a server socket....and in finally clause i close the socket.

    now most of the time this works fine.

    however while im still testing my program is crashes sometimes.
    then removing bind exception is annoying.

    isnt there anyway (like as it is in jacORB) to check for and remove stale reference on a port???

    Message was edited by:
    luqman

    DB:2.74:Stale Server Socket Reference fx

    http://java.sun.com/j2se/1.5.0/docs/api/java/net/Serve
    rSocket.html#setReuseAddress(boolean)

    Set this to 'true'.

    Development only, don't let this leak into production.thanks works perfect now.

  • RELEVANCY SCORE 2.74

    DB:2.74:Not Reading 8m



    Hello,

    import flash.net.Socket;

    public var socket:Socket;

    public function socketData():void

    {

    socket = new Socket();

    socket.connect("localhost", 1234);

    socket.addEventListener(ProgressEvent.SOCKET_DATA, progressEvent);

    }

    public function progressEvent(event:ProgressEvent):void

    {

    socket.writeUTFBytes("ARRIVAL OF DATA \n");

    socket.flush();

    var data:String = socket.readUTFBytes(socket.bytesAvailable);

    textarea.text += data;

    }

    The client is getting the data but the server is not getting the data

    ?php

    $host = "localhost";$port = 1234;

    set_time_limit(0);

    $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");

    $result = socket_listen($socket, 3) or die("Could not set up socket listener\n");

    $comSocket = socket_accept($socket) or die("Could not accept incoming connection\n");

    echo $socketInput=socket_read($comSocket,1024); // if i comment this line client is getting the data "DATA ARRIEVED". Not displaying anything if i uncomment it

    socket_write($comSocket, "DATA ARRIEVED");

    ?

    Thanks

    DB:2.74:Not Reading 8m


    Hello,

    import flash.net.Socket;

    public var socket:Socket;

    public function socketData():void

    {

    socket = new Socket();

    socket.connect("localhost", 1234);

    socket.addEventListener(ProgressEvent.SOCKET_DATA, progressEvent);

    }

    public function progressEvent(event:ProgressEvent):void

    {

    socket.writeUTFBytes("ARRIVAL OF DATA \n");

    socket.flush();

    var data:String = socket.readUTFBytes(socket.bytesAvailable);

    textarea.text += data;

    }

    The client is getting the data but the server is not getting the data

    ?php

    $host = "localhost";$port = 1234;

    set_time_limit(0);

    $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");

    $result = socket_listen($socket, 3) or die("Could not set up socket listener\n");

    $comSocket = socket_accept($socket) or die("Could not accept incoming connection\n");

    echo $socketInput=socket_read($comSocket,1024); // if i comment this line client is getting the data "DATA ARRIEVED". Not displaying anything if i uncomment it

    socket_write($comSocket, "DATA ARRIEVED");

    ?

    Thanks

  • RELEVANCY SCORE 2.74

    DB:2.74:Java Socket - Port Knocking m7


    Hi
    I'm new here sorry if this subject was already discusssed. I was trying to find answer without result.

    I have to write simle client for port knocking technique in java, and i have little problem
    Port knocking daemon works fine (easy just read firewall logs) but client i sending many packets instead of one... When server is behind the firewall
    To "knock" to the server I'm using quite simle command:

    Socket S = new Socket(ip,port);

    Dou you have any idea how to make it work. I need this client to knock only once..

    Cheers,
    PP5585

    DB:2.74:Java Socket - Port Knocking m7

    You lost me. What are talking about. By using a standard socket connection and trying to connect to some port on a remote server, all that would happen is either a connection or a refusal or time-out.

  • RELEVANCY SCORE 2.73

    DB:2.73:How To Set The Max Number Of Connection When Using Serversocketchannel 1d


    I use ServerSocketChannel with Non-block configuration for server, I want to limited the clients to connect with the server, how can I refuse the new coming connection when the current number of connection equal the Max number of connection?

    acceptSelector = SelectorProvider.provider().openSelector();

    // Create a new server socket and set to non blocking mode
    server = ServerSocketChannel.open();

    server.configureBlocking(false);

    // Bind the server socket to the local host and port
    InetSocketAddress isa = new InetSocketAddress(InetAddress
    .getLocalHost(), port);

    server.socket().bind(isa);

    // Register accepts on the server socket with the selector. This
    // step tells the selector that the socket wants to be put on the
    // ready list when accept operations occur, so allowing multiplexed
    // non-blocking I/O to take place.
    SelectionKey acceptKey = server.register(acceptSelector,
    SelectionKey.OP_ACCEPT);

    int keysAdded = 0;
    // Here's where everything happens. The select method will
    // return when any operations registered above have occurred, the
    // thread has been interrupted, etc.
    while ((keysAdded = acceptSelector.select()) 0)
    {
    // Someone is ready for I/O, get the ready keys
    SetSelectionKey readyKeys = acceptSelector.selectedKeys();
    IteratorSelectionKey i = readyKeys.iterator();

    // Walk through the ready keys collection and process date
    // requests.
    while (i.hasNext())
    {
    SelectionKey sk = (SelectionKey) i.next();
    i.remove();
    // The key indexes into the selector so you
    // can retrieve the socket that's ready for I/O
    ServerSocketChannel nextReady = (ServerSocketChannel) sk
    .channel();
    // Accept the date request and send back the date string
    Socket s = nextReady.accept().socket();
    pool.execute(new Handler(s));
    }
    }

    DB:2.73:How To Set The Max Number Of Connection When Using Serversocketchannel 1d

    (a) Set the 'backlog' parameter when binding. This will limit the number of outstanding connection requests.

    (b) You can only refuse a connection by accepting it and then closing it immediately.

    It might be better to just make the excess clients wait:

    (c) When a newly accepter SocketChannel means you have just reached the required number of clients, deregister the ServerSocketChannel for OP_ACCEPT

    (d) when any client closes, re-register the ServerSocketChannel for OP_ACCEPT.

    This will prevent you from accepting any new connections while you are already handling the maximum number.

  • RELEVANCY SCORE 2.73

    DB:2.73:Problem With Application Server zp


    Hii have some problem with App server..bash-2.05$ ./startWebLogic.sh.Mar 23, 2005 10:04:35 AM MST Emergency WebLogicServer BEA-000351 Unable to create a server socket on Channel Default for port: 7001. java.net.BindException: Address already in use Perhaps another process is using port 7001. Mar 23, 2005 10:04:35 AM MST Emergency Security BEA-090085 Server failed to bind to the configured port. The port may already be used by another process. Mar 23, 2005 10:04:35 AM MST Emergency WebLogicServer BEA-000342 Unable to initialize the server: Server failed to bind to the requested port. See preceeding log message for details. ***************************************************************************The WebLogic Server did not start up properly.Exception raised: 'weblogic.server.ServerLifecycleException: Server failed to bind to the requested port. See preceeding log message for details.'Reason: Server failed to bind to the requested port. See preceeding log message for details.***************************************************************************can anyone advise me what to do..Thanks in Advance.

    DB:2.73:Problem With Application Server zp

    1/ Open config.xml and change the port from 7001 to 6001 (for example). 2/ Restart the BEA serviceMessage was edited by: porfila

  • RELEVANCY SCORE 2.73

    DB:2.73:Serversocket/Socket pz


    I have the following code for Server Socket
    ServerSocket ss = new ServerSocket(36281);

    I have the following Socket code to connect to the server.
    Socket clientSocket = new Socket("xxx.xxx.xxx.xxx", 36281);

    If i specify the IP in Socket as a local IP then it connects to the server's port, but if i
    specify a internet static/dynamic IP then i have problem connecting to the port.
    If i try to connect to Port 80 it works but when i specify a custom port it fails.
    I have diabled all the firewall, antivirus software and also added the above port in windows firewall exception list.
    In my modem i have configured the dmz to my system IP, but still i am not able to connect to the port.

    Please let me know how to get the connection working. What is that blocking the port for connection.

    DB:2.73:Serversocket/Socket pz

    If it works for port 80 but not this port it sounds like a network/firewall/proxy issue.
    I would see if you can telnet to the port locally and remotely (i.e. take the Java client out of the equation)

    Configuration of a network isn't really a Java Programming question.

  • RELEVANCY SCORE 2.73

    DB:2.73:The Problem On Sctp When Using Sctp_Sendmsg 9k


    Dear all,

    I tried to create the small program to understand how client and server
    work on SCTP. I created two different kinds of program, one is for 1 to
    1 sctp socket and another is 1 to many socket. The first one, 1 to 1
    socket, is working well but the second one.

    My program for the 1 to many socket is that client send the data to the
    server to establish the connecttion with sctp_sendsmg() and the server
    calls sctp_rcvmsg() to receive the data from the client. This is still
    fine. But the problem is when server want to send data back to client,
    the error is shown. The error message from strerror (errno) is "Address
    already in use".

    Could someone tell me what is wrong with my program?

    #include stdio.h
    #include strings.h
    #include iostream.h
    #include sys/types.h
    #include sys/socket.h
    #include netinet/in.h
    #include unistd.h
    #include errno.h
    #include arpa/inet.h
    #include netinet/sctp.h
    #include sys/uio.h
    #include stdlib.h

    #define BACKLOG 5
    #define SERV_PORT 47123
    #define MAX_MSG 100
    #define MSG_SIZE (MAX_MSG+1)
    #define AUTO_CLOSING_TIME 60
    #define SERV_IP htonl(0x7f000001)

    int main(){

    struct sockaddr_in servaddr, clientaddr;
    int sockfd, confd, msg_flags;
    socklen_t len;
    char str[16];
    char line[MSG_SIZE];
    struct sctp_event_subscribe events;
    struct sctp_sndrcvinfo sockinfo;
    // To creat a 1 to M SCTP socket
    sockfd = ::socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
    if(sockfd 0){
    char* errmsg = strerror (errno);
    cout "Creating socket is failed : " errmsg "\n";
    return 0;
    }
    else{
    cout "Creating socket is successful : " sockfd "\n";
    }

    // To bind a primary IP address to the socket
    bzero(servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = inet_addr("192.168.139.94");
    servaddr.sin_port = htons (SERV_PORT);
    if(::bind(sockfd, (struct sockaddr*) servaddr, sizeof(servaddr) )
    0){
    char* errmsg = strerror (errno);
    cout "Binding Address to socket is failed : " errmsg "\n";
    return 0;
    }
    else{
    cout "Binding Address to socket is successful with" "\n";
    }
    // To bind more IP addresses to the socket
    struct sockaddr_in addrset[2];
    for (int i = 0; i 2; i++) {
    addrset.sin_family = AF_INET;
    addrset[i].sin_port = htons(SERV_PORT);
    }
    addrset[0].sin_addr.s_addr = inet_addr("192.168.139.93");
    addrset[1].sin_addr.s_addr = SERV_IP;
    if(sctp_bindx(sockfd, (struct sockaddr*) addrset[0], 2,
    SCTP_BINDX_ADD_ADDR) 0){
    char* errmsg = strerror (errno);
    cout "Binding more addresses is failed : " errmsg "\n";
    }
    else{
    cout "Binding more addresses is successful\n";
    }

    bzero (events, sizeof (events)) ;
    events.sctp_data_io_event = 1;

    if(::setsockopt(sockfd, IPPROTO_SCTP, SCTP_EVENTS, events,
    sizeof(events) ) 0){
    char* errmsg = strerror (errno);
    cout "Setting data io option is failed : " errmsg "\n";
    return 0;
    }
    else{
    cout "Setting data io option is successful" "\n";
    }

    if(::listen (sockfd, BACKLOG) 0){
    char* errmsg = strerror (errno);
    cout "Listenning is failed : " errmsg "\n";
    return 0;
    }
    else{
    cout "Listenning is successful\n";
    }

    while(true){
    cout "Waiting for SCTP connection on port " SERV_PORT "
    ...\n";

    memset(line, 0x0, MSG_SIZE);
    while (true) {
    int recv_msg_size = sctp_recvmsg(sockfd, line, sizeof(line),
    (struct sockaddr*) clientaddr, len, sockinfo, msg_flags );
    if(recv_msg_size 0){
    char* errmsg = strerror (errno);
    cerr "Error: cannot send data: " errmsg "\n";
    }
    else{
    cout "---" line "----\n";
    cout "---" sizeof(line) " : " recv_msg_size "----\n";
    cout "---" inet_ntoa(clientaddr.sin_addr) "----\n";
    cout "---" ntohs(clientaddr.sin_port) "----\n";
    cout "---" sockinfo.sinfo_assoc_id "----\n";
    cout "---" sockinfo.sinfo_stream "----\n";
    }

    sockinfo.sinfo_stream++;

    if (::sctp_sendmsg(sockfd, line, sizeof(line), (struct
    sockaddr*) clientaddr, len, sockinfo.sinfo_ppid, sockinfo.sinfo_flags,
    sockinfo.sinfo_stream, 0, 0) 0){
    char* errmsg = strerror (errno);
    cerr "Error: cannot send data: " errmsg "\n";
    }
    memset(line, 0x0, MSG_SIZE); // set line to all zeroes
    }
    }

    if (::close(sockfd) 0){
    char* errmsg = strerror (errno);
    cout "Socket closing is failed : " errmsg "\n";
    }
    else{
    cout "Socket closing is successful\n";
    }
    return 0;

    }

    Thank you

    DB:2.73:The Problem On Sctp When Using Sctp_Sendmsg 9k

    I'm having the same problem, even if I use 1-to-1.
    I just can't seem to use the sctp_bindx method on solaris 10.(works fine for me on linux)
    Has anyone succeeded ?

    Thanks,

    Edo

  • RELEVANCY SCORE 2.73

    DB:2.73:Datagramsocket Listener Is Not Getting Messagereceived Call Back z1


    Hello,
    1) I am trying tolisten a UDP port using DatagramSocket in a WinRT app. The server is in the same machine. Also I have enabled the capability Private Networks(Client Server). I am using the following code below to achieve this:-
    DatagramSocket listener = new DatagramSocket();
    listener.MessageReceived = Message_Received;
    HostName windowsHostname = new HostName(127.0.0.1);
    try
    {
    await listener.BindEndpointAsync(windowsHostname, port_number);
    //await listener.ConnectAsync(windowsHostname, port_number);
    // await listener.BindServiceNameAsync(port_number);
    Debug.WriteLine(After calling async bind);
    }
    catch(Exception exception)
    {
    Debug.WriteLine(inside catch);
    Debug.WriteLine(exception.HResult. {0}, exception.HResult.ToString());
    if(SocketError.GetStatus(exception.HResult) == SocketErrorStatus.Unknown)
    {
    Debug.WriteLine(inside throw);
    throw;
    }
    }

    async void Message_Received(DatagramSocket socket, DatagramSocketMessageReceivedEventArgs eventArguments)
    {
    Debug.WriteLine(inside Message_Received);
    }
    In the try block as you can see, I tried using all 3 bind methods, still no reply on Message_Received. I don't get any exception or any output log though. There is one more test app using MFC which is working fine (listening gets message callbacks).
    Can you please let me know what could be missing OR is it possible at all with this.
    2) I also tried to modify the SDK sample given my MSDN for DatagramSockets, (DatagramSocket sample)
    And changed the port number to my desired port number, still I don't get a call back. The SDk sample gets messages only from its own clients hello message in step 3.
    Please throw some light on the same.
    Thanks in Advance

    DB:2.73:Datagramsocket Listener Is Not Getting Messagereceived Call Back z1

    DatagramSocket does not allow datagram from other processes running in the same machine, not even when enabling loopback exemptions, unless the datagram comes from the same app.

    It is different when sending datagrams. Sending datagramas to other processes running in the same machine is allowed ONLY when loopback exemptions are enabled, for testing purposes.

  • RELEVANCY SCORE 2.72

    DB:2.72:Osd, Wds And Pxe Issue - Pxe Service Point Not Responding - Error 10048 ak


    Hi all,

    Have the common PXE-E53 No boot filename received issue, but can't get to the bottom of it this time.

    DHCP Server and PXE Service Point on different servers, in same subnet. Client in different subnet, IP Helper configured forwarding to both. (Have tried using DHCP Options 60,66,67 with no difference).

    On SCCM PXE Service Point, WDS running without error. PXE Service Point running, but the following error
    PXE Control Manager detected PXE service point is not responding to PXE requests. The error is 10048.
    PXEControl.log has the following which seems to indicate a bind issue?

    )
    SMS_PXE_SERVICE_POINT successfully STARTED.
    ********************************************************************************
    Configuration and Availability Monitor thread started.
    Initialized 'SMS Server Availability' performance instance = SMS PXE Service Point.
    adding address to server list 10.01.101.146
    adding address to server list 127.00.00.01
    Bind Socket Failed
    Error initializing PXE client
    Bind Socket Failed
    Error initializing PXE client
    Pxe test request failed, error code is 10048.
    STATMSG: ID=6319 SEV=E LEV=M SOURCE=SMS Server COMP=SMS_PXE_SERVICE_POINT SYS=xxx36 SITE=SV0 PID=4600 TID=1676 GMTDATE=Fri Nov 12 16:26:29.760 2010 ISTR0=10048 ISTR1= ISTR2= ISTR3= ISTR4= ISTR5= ISTR6= ISTR7= ISTR8= ISTR9= NUMATTRS=0
    SMS_PXE_SERVICE_POINT
    PXE test request failed, status code is -2147014848, 'Error initializing PXE client'.
    Successfully performed availability check against local computer.
    Initialization still in progress.

    Thanks in advance for any ideas of what to check next.

    DB:2.72:Osd, Wds And Pxe Issue - Pxe Service Point Not Responding - Error 10048 ak

    Hi Eric !

    I have the exact same issue as GarW, although it seems to me no third party application are usingthe WDS/PXE service.

    nsetstat -b gives me this
    ------Filtered out anything but WDS---------
    ProtoLocal AddressForeign AddressStatePIDEXE
    TCPanl01-ms001:7109anl01-ms001.global.to:1026ESTABLISHED1224[svchost.exe]WDSServer
    TCPanl01-ms001:7760anl01-ms001.global.to:msft-gcESTABLISHED1224[svchost.exe]WDSServer
    TCPanl01-ms001:7761anl01-ms001.global.to:epmapESTABLISHED1224[svchost.exe]WDSServer
    TCPanl01-ms001:7097anl01-ms001.global.to:ldapCLOSE_WAIT1224[svchost.exe]WDSServer
    ----------------------------------------------------
    netstat -n gives me 296 connections// Lundegard

  • RELEVANCY SCORE 2.72

    DB:2.72:Problem Setting 7606 Router For Tacacs+ Authentication xa



    Hello Support Community,

    I have two Cisco 7606 routers which I have tried in vain to have users authenticated using TACACS+ servers. As shown below, I have two servers (1.1.1.1 and 2.2.2.2) reachable via vrf OAM which is reachable from desktops for ssh login. The true IP addresses and vrf have been altered because it's a company router.

    I use the two servers to authenticate many other Cisco devices in the network they are working fine.

    I can reach the servers from the vrf and the source interface in use. I can also telnet port 49 if the servers from the source interface and the vrf.

    The server key is hidden but at the time of configuration, I can ascertain that it's correct.

    The problem is that after confuring for TACACS authentication, the router still uses the enable password instead of TACACS. While the debug output shows 'bad password', why is the router not authenticating using TACACS? Why is it using the enable password?

    Please study the outputs below and help point out what I may need to change.

    PS: I have tried out many other combinations, including deprecated ones without success including the method suggested in this page;

    http://www.cisco.com/en/US/docs/ios/sec_user_services/configuration/guide/sec_vrf_tacas_svrs.html

    Please help I'm stuck.

    ROUTER#sh running-config | sec aaa

    aaa new-model

    aaa group server tacacs+ admin

    server name admin

    server name admin1

    ip vrf forwarding OAM

    ip tacacs source-interface GigabitEthernet1

    aaa authentication login admin group tacacs+ local enable

    aaa session-id common

    ROUTER#sh running-config | sec tacacs

    aaa group server tacacs+ admin

    server name admin

    server name admin1

    ip vrf forwarding OAM

    ip tacacs source-interface GigabitEthernet1

    aaa authentication login admin group tacacs+ local enable

    tacacs server admin

    address ipv4 1.1.1.1

    key 7 XXXXXXXXXXXXXXXXXXXX

    tacacs server admin1

    address ipv4 2.2.2.2

    key 7 XXXXXXXXXXXXXXXXxxxx

    line vty 0 4

    login authentication admin

    ROUTER#sh tacacs

    Tacacs+ Server -  public  :

                   Server name: admin

                Server address: 1.1.1.1

                   Server port: 49

                  Socket opens:         15

                 Socket closes:         15

                 Socket aborts:          0

                 Socket errors:          0

               Socket Timeouts:          0

       Failed Connect Attempts:          0

            Total Packets Sent:          0

            Total Packets Recv:          0

    Tacacs+ Server -  public  :

                   Server name: admin1

                Server address: 2.2.2.2

                   Server port: 49

                  Socket opens:         15

                 Socket closes:         15

                 Socket aborts:          0

                 Socket errors:          0

               Socket Timeouts:          0

       Failed Connect Attempts:          0

            Total Packets Sent:          0

            Total Packets Recv:          0

    Oct 22 12:38:57.587: AAA/BIND(0000001A): Bind i/f 

    Oct 22 12:38:57.587: AAA/AUTHEN/LOGIN (0000001A): Pick method list 'admin'

    Oct 22 12:38:57.587: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:38:57.587: AAA/AUTHEN/ENABLE(0000001A): Done status GET_PASSWORD

    Oct 22 12:39:02.327: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:39:02.327: AAA/AUTHEN/ENABLE(0000001A): Done status FAIL - bad password

    Oct 22 12:39:04.335: AAA/AUTHEN/LOGIN (0000001A): Pick method list 'admin'

    Oct 22 12:39:04.335: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:39:04.335: AAA/AUTHEN/ENABLE(0000001A): Done status GET_PASSWORD

    Oct 22 12:39:08.675: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:39:08.675: AAA/AUTHEN/ENABLE(0000001A): Done status FAIL - bad password

    Oct 22 12:39:10.679: AAA/AUTHEN/LOGIN (0000001A): Pick method list 'admin'

    Oct 22 12:39:10.683: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:39:10.683: AAA/AUTHEN/ENABLE(0000001A): Done status GET_PASSWORD

    Oct 22 12:39:14.907: AAA/AUTHEN/ENABLE(0000001A): Processing request action LOGIN

    Oct 22 12:39:14.907: AAA/AUTHEN/ENABLE(0000001A): Done status FAIL - bad password

    ROUTER#sh ver

    Cisco IOS Software, c7600rsp72043_rp Software (c7600rsp72043_rp-ADVIPSERVICESK9-M), Version 15.1(3)S3, RELEASE SOFTWARE (fc1)

    Technical Support: http://www.cisco.com/techsupport

    Copyright (c) 1986-2012 by Cisco Systems, Inc.

    Compiled Fri 30-Mar-12 08:34 by prod_rel_team

    ROM: System Bootstrap, Version 12.2(33r)SRE, RELEASE SOFTWARE (fc1)

    BOOTLDR: Cisco IOS Software, c7600rsp72043_rp Software (c7600rsp72043_rp-ADVIPSERVICESK9-M), Version 15.1(3)S3, RELEASE SOFTWARE (fc1)

    ROUTER uptime is 7 weeks, 5 days, 16 hours, 48 minutes

    Uptime for this control processor is 7 weeks, 5 days, 16 hours, 49 minutes

    System returned to ROM by reload (SP by reload)

    System restarted at 20:00:59 UTC Wed Aug 28 2013

    System image file is "sup-bootdisk:c7600rsp72043-advipservicesk9-mz.151-3.S3.bin"

    Last reload type: Normal Reload

    Last reload reason: power-on

    This product contains cryptographic features and is subject to United

    States and local country laws governing import, export, transfer and

    use. Delivery of Cisco cryptographic products does not imply

    third-party authority to import, export, distribute or use encryption.

    Importers, exporters, distributors and users are responsible for

    compliance with U.S. and local country laws. By using this product you

    agree to comply with applicable laws and regulations. If you are unable

    to comply with U.S. and local laws, return this product immediately.

    A summary of U.S. laws governing Cisco cryptographic products may be found at:

    http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

    If you require further assistance please contact us by sending email to

    export@cisco.com.

    Cisco CISCO7606-S (M8500) processor (revision 1.1) with 3670016K/262144K bytes of memory.

    Processor board ID FOX1623G61B

    BASEBOARD: RSP720

    CPU: MPC8548_E, Version: 2.1, (0x80390021)

    CORE: E500, Version: 2.2, (0x80210022)

    CPU:1200MHz, CCB:400MHz, DDR:200MHz,

    L1:    D-cache 32 kB enabled

            I-cache 32 kB enabled

    Last reset from power-on

    3 Virtual Ethernet interfaces

    76 Gigabit Ethernet interfaces

    8 Ten Gigabit Ethernet interfaces

    3964K bytes of non-volatile configuration memory.

    500472K bytes of Internal ATA PCMCIA card (Sector size 512 bytes).

    Configuration register is 0x2102

    DB:2.72:Problem Setting 7606 Router For Tacacs+ Authentication xa


    Sorry for the delay in response. I have made the change as you recommended and it has worked! Thank you very much.

    There are many variations of how to implement this on different types of devices but this has done it for the 7606.

  • RELEVANCY SCORE 2.72

    DB:2.72:How To Run Standalone Server As A Service In Linux mc


    Hi,

    I need run an Standalone server in Java as a Service in Linux RedHat?

    How to do this? some example or link to helpful sample code?

    How I can execute as a service in Linux RedHat 9 the following server Application?

    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    import java.nio.channels.spi.*;
    import java.net.*;
    import java.util.*;

    // Listen on a port for connections and write back the current time.
    public class NBTimeServer_1 {
    private static final int DEFAULT_TIME_PORT = 8900;

    // Constructor with no arguments creates a time server on default port.
    public NBTimeServer_1() throws Exception {
    acceptConnections(this.DEFAULT_TIME_PORT);
    }

    // Constructor with port argument creates a time server on specified port.
    public NBTimeServer_1(int port) throws Exception {
    acceptConnections(port);
    }

    // Accept connections for current time. Lazy Exception thrown.
    private static void acceptConnections(int port) throws Exception {
    // Selector for incoming time requests
    Selector acceptSelector = SelectorProvider.provider().openSelector();

    // Create a new server socket and set to non blocking mode
    ServerSocketChannel ssc = ServerSocketChannel.open();
    ssc.configureBlocking(false);

    // Bind the server socket to the local host and port

    //InetAddress lh = InetAddress.getLocalHost();
    InetSocketAddress isa = new InetSocketAddress(port);
    ssc.socket().bind(isa);

    SelectionKey acceptKey = ssc.register(acceptSelector,
    SelectionKey.OP_ACCEPT);

    int keysAdded = 0;

    while ((keysAdded = acceptSelector.select()) 0) {
    // Someone is ready for I/O, get the ready keys
    Set readyKeys = acceptSelector.selectedKeys();
    Iterator i = readyKeys.iterator();

    // Walk through the ready keys collection and process date requests.
    while (i.hasNext()) {
    SelectionKey sk = (SelectionKey)i.next();
    i.remove();

    ServerSocketChannel nextReady =
    (ServerSocketChannel)sk.channel();
    // Accept the date request and send back the date string
    Socket s = nextReady.accept().socket();

    // Write the current time to the socket
    ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
    oos.writeObject(new Zaehler("usr","msg"));

    }
    }
    }

    I thanks in Advance your valuable help.

  • RELEVANCY SCORE 2.72

    DB:2.72:Unable To Initialize The Server: Server Failed To Bind To The Requested Por kd


    I am facing the error while starting the server. I see the following error.
    Sep 26, 2007 11:49:54 PM EDT Emergency WebLogicServer BEA-000350 Unable to create a server socket on Channel Default for: 162.86.20.87, port: 8101. java.net.BindException: Address already in use Perhaps the address 162.86.20.87 is incorrect or another process is using port 8101.
    Sep 26, 2007 11:49:54 PM EDT Emergency Security BEA-090085 Server failed to bind to the configured port. The port may already be used by another process.
    Sep 26, 2007 11:49:54 PM EDT Emergency WebLogicServer BEA-000342 Unable to initialize the server: Server failed to bind to the requested port. See preceeding log message for details.
    ***************************************************************************
    The WebLogic Server did not start up properly.
    Exception raised: 'weblogic.server.ServerLifecycleException: Server failed to bind to the requested port. See preceeding log message for details.'
    Reason: Server failed to bind to the requested port. See preceeding log message for details.
    ************************************************************************
    If the port is already in use how to find which server is running on that port, how to find the process and kill it. I am using weblogic 8.1 sp4 in Solaris 8.

    DB:2.72:Unable To Initialize The Server: Server Failed To Bind To The Requested Por kd

    I am facing the error while starting the server. I see the following error.
    Sep 26, 2007 11:49:54 PM EDT Emergency WebLogicServer BEA-000350 Unable to create a server socket on Channel Default for: 162.86.20.87, port: 8101. java.net.BindException: Address already in use Perhaps the address 162.86.20.87 is incorrect or another process is using port 8101.
    Sep 26, 2007 11:49:54 PM EDT Emergency Security BEA-090085 Server failed to bind to the configured port. The port may already be used by another process.
    Sep 26, 2007 11:49:54 PM EDT Emergency WebLogicServer BEA-000342 Unable to initialize the server: Server failed to bind to the requested port. See preceeding log message for details.
    ***************************************************************************
    The WebLogic Server did not start up properly.
    Exception raised: 'weblogic.server.ServerLifecycleException: Server failed to bind to the requested port. See preceeding log message for details.'
    Reason: Server failed to bind to the requested port. See preceeding log message for details.
    ************************************************************************
    If the port is already in use how to find which server is running on that port, how to find the process and kill it. I am using weblogic 8.1 sp4 in Solaris 8.

  • RELEVANCY SCORE 2.72

    DB:2.72:Forcing Web Server To Reject Connections s7



    Is it possible to programtically stop WebLogic Server from accepting connections
    to the web server? We have a hardware load balancer that is fairly dumb and uses
    simple TCP socket connection tests to determine if a server is still available.
    In some cases, we detect fatal errors in our components and would like to take
    the WebLogic Server instance offline without killing the process. Ideally, we
    want to programatically close the web server port so the load balancer thinks
    the server is dead and stops directing traffic to it.

    Has anyone done this?

    Thanks,

    Andy Riedel
    Core Mobility

    DB:2.72:Forcing Web Server To Reject Connections s7

    Close the port.

    Peace,

    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic

    "Andy Riedel" ariedel@coremobility.com wrote in message
    news:3e4dac1a@newsgroups.bea.com...

    Is it possible to programtically stop WebLogic Server from acceptingconnections
    to the web server? We have a hardware load balancer that is fairly dumband uses
    simple TCP socket connection tests to determine if a server is stillavailable.
    In some cases, we detect fatal errors in our components and would like totake
    the WebLogic Server instance offline without killing the process. Ideally,we
    want to programatically close the web server port so the load balancerthinks
    the server is dead and stops directing traffic to it.

    Has anyone done this?

    Thanks,

    Andy Riedel
    Core Mobility

  • RELEVANCY SCORE 2.72

    DB:2.72:Ntp - How To Monitor For Broadcast Messages ad


    I am trying to develop an application in Java that will send a request to an NTP server and get a response back from it, carry out synchronisation, maybe repeat this and if time synch is within tolerance then just sit back and wait for an NTP broadcast message, when this arrives carry out a synch check and if still in tolerance carry on waiting for the next broadcast message or else go back into the first part and request a time message, etc. Code has been based on that produced by Adam Buckley and widley available on the net.

    The first part seems to be OK. I can send the request to the server and get back a response. The problem is waiting for the broadcast message. I cant get the code to monitor for broadcast messages. In Java you seem to have to set up a socket which by definition has to be on port 123. This always fails with a bind exception because the socket is in use; although there is no evidence anywhere it is in use except where it was used in the first part. My network broadcast address is 192.0.0.255

    If I monitor the system (with snoop) I can see the broadcast messages being sent at about 64 second intervals.

    I am using a Solaris/Unix system with Java 1.6_14, and am using RFC1769 Simple Network Time Protocol and TR-06-6-1 NTPv4, Reference and Implementation Guide, June 2006 as my reference documents.

    Does my unix workstation need to be NTP enabled in order for me to capture these messages? I don't see why it should be if I can see the messages on the network! I just can't get the code to monitor the broadcast address without specifying a port number and if I use 123 I get the bind error, if I use any other number I don't receive the datagram message.

    Any help much appreciated.

    Regards
    Roger

    DB:2.72:Ntp - How To Monitor For Broadcast Messages ad

    Ah! kajbj thank you - I have tried running the code as root and hey presto it worked. I was then able to put a loop around it and watch it receive broadcast packets every 64 seconds or so.

    So Thanks very much, it's amazing what a little knowledge can do
    And all knowledge is power!

    Thanks also to ejp for the info on netstat -an that also helped because I had been playing with ntp.conf and had configured my workstation as an Ntp client and obviously was also trying to access port 123. So this helped me sort this out.

    I will also have a look at taiclock, etc from YoungWinston.

    Thanks guys.

  • RELEVANCY SCORE 2.71

    DB:2.71:Netcool Integration px



    Hi All,

    We are doing Netcool integration with service now and using out of the box plugin.

    We were able to install Mid Server on the Linux Box, successfully and it made a successful connection with the Service now as well.

    We are trying to establish the Socket Monitor and whenever I clicked Start, after few minutes it is stopped.

    I tried it with checking Start Socket Writer and also without checking that box and still it doesn't work.

    We are trying to achieve this on Port 4444.

    Any help would be appreciated.

    Best Regards,

    Namrata Jain

    DB:2.71:Netcool Integration px


    Hi All,

    We are doing Netcool integration with service now and using out of the box plugin.

    We were able to install Mid Server on the Linux Box, successfully and it made a successful connection with the Service now as well.

    We are trying to establish the Socket Monitor and whenever I clicked Start, after few minutes it is stopped.

    I tried it with checking Start Socket Writer and also without checking that box and still it doesn't work.

    We are trying to achieve this on Port 4444.

    Any help would be appreciated.

    Best Regards,

    Namrata Jain

  • RELEVANCY SCORE 2.71

    DB:2.71:Bes 5 With 2 Exchange 2007 Servers zk



    Hi,

    I have had BES 5.0 setup for a couple of weeks with no problems to 1 exchange server. Since adding a user from another exchange server the BES will only spawn 1 BlackBerryAgent.exe process. The app log has the error:

    ExtUDPLogThread: Failed to bind to socket(4085), error(10022)

    from port 4085 through to 4499

    ExtUDPLogThread: Failed to bind to socket(4499), error(10022)

    Any ideas about how to troubleshoot this would be most welcome.

    Thanks

    Dan
    Message Edited by spodboy on 07-20-2009 11:07 AM

    DB:2.71:Bes 5 With 2 Exchange 2007 Servers zk

    -Apply the resolution as per Microsoft KB946886



    *****************************************************************************Click on KUDOS to appreciate our efforts and mark the thread RESOLVED if your issue is resolved.

  • RELEVANCY SCORE 2.71

    DB:2.71:Client Socket Port j1


    Hi,

    When opening a client connection there are two ways how the port can be selected; either allowing the system to select a random port or else decide on which local port the socket should work. So far I have always allowed the system to select the port for me. However I am now writing a server application where the server need to identify the client from the socket remote address and port. So would it be a good design if I actually bind my client application to always work on a particular port or I should consider other (better) designs on how the application can recognize the client application.

    Please do net hesitate to tell me should you need more information about the scenario.

    Regards,
    Sim085

    DB:2.71:Client Socket Port j1

    Hi,

    Sorry for the dealy and thanks for the replies. They are really helpfull and at least help me to think of a better design :)

    @cotton.m
    What I don't really understand is how on the one hand these clients seem
    to be out of your control and yet on the other hand you wanted to bind specific
    ports on the client side which implies you do have some control after all.I am sorry for the confusion. I do not have full control on the client applications since some of these clients where developed by us and others where not. This is not my official project and am only trying to find a solution so I can improve my design skills. When I did the first post I assumed I could do that on all the clients. By the next post I realised that not all clients had this feature (some of them have) and so I rubished the design immediatly.

    @ejp
    If you have N different protocols then in general you need N different
    listening ports at the server end.Thanks, that was the answer I have been waiting for :) I can still improve the design by making a single server with plugganable end points... Each end point would then need to open a new socket server on a different port. Like that my company would only need to develop an end point when a new client arrives :)

    Thanks again to you both :) I was always confused if the most simple design was the good one. Now I know it is :)

    Thanks and Regards,
    Sim085

  • RELEVANCY SCORE 2.71

    DB:2.71:Socket Port Release j7


    I am using Socket programming to implement a listen thread on a machine. I am using port 80 for this application. I want my application to resume even if the network cable to machine is disconnected and connected back again. Now my application is running on a specific IP bound to a specific port. When network cable is disconnected and connected back again the IP address changes. What I am doing is closing the old listen thread (when reconnected) and opening a new one on the same socket connection (now having a new IP and old port - 80). It is working fine till my machine is allocated some same old IP. At this point when I am trying to bind to port 80 the error I am getting is 10048 (WSAEADDRINUSE) which means that the socket was not released for that particular IP address on that port.  (Although I am able to bind to the same port with a new IP address - problem comes only when some old IP address is reallocated to machine)
    Is there any way to rebind or unbind the socket or refresh the same socket with the new IP without having to close the socket and opening it again (since that will take a lot of time)?
    Thank you in advance for your suggestions!

    DB:2.71:Socket Port Release j7

    Make sure to close old sockets before you bind to a new address, instead of just terminating the thread.

  • RELEVANCY SCORE 2.71

    DB:2.71:Socket Not Released zd


    Hi,I
    currently have an app that spawns a connection to server, the server
    requires hard IP and Port for both my app and the server itself.  It
    then sends a command and disconnects.  The problem is that I have to
    wait ~5 minutes for the socket to become usable again.  I know that
    windows likes to maintain the socket for a few minutes.  Any idea on
    how I can get around this.  I call the socket.close() method when I am
    done sending my parameters.  I tried setting     socket.setSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true)but
    it does not seem to release the socket fast enough (still taking ~5 minutes) for me to spawn new
    connections.  The hard IP and port can not be changed (unfortunatly for
    me).  Does anyone know of a way to drop a socket connection and release
    the resources immediatly so I can bind a new socket and send another
    command?  Thanks for your helpTom

    DB:2.71:Socket Not Released zd

    Well, you probably need to do some analysis as to the actual amount of data on the network. If you are reconnecting often, the network traffic of establishing the connection may be more than the overhead of keeping the connection alive.Also, if I remember right, the sending of keepalive packets is something you opt into (not on by default), so the cost of keeping the connection alive may not be as bad as you think. You will have to do your own analysis to make sure, but I think it is worth the effort in this case.
    Of course, this all depends on whether the server will even allow you to keep the connection alive...

  • RELEVANCY SCORE 2.71

    DB:2.71:Unable To Create Server Socket 89


    After I use weblogic.Admin to shutdown weblogic server, I restart it and I
    got the following message. I've to reboot NT to make it work. Why are the
    ports still opened even though no WebLogic server is running?

    Tue Oct 03 12:07:49 EDT 2000:! ListenThread **** Unable to create server
    socket. Perhaps another process is using port: '7001'.
    java.net.BindException: Address in use: bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:390)
    at java.net.ServerSocket.init(ServerSocket.java:173)
    at java.net.ServerSocket.init(ServerSocket.java:124)
    at weblogic.t3.srvr.ListenThread.newServerSocket(ListenThread.java:214)
    at weblogic.t3.srvr.ListenThread.run(ListenThread.java, Compiled Code)
    Tue Oct 03 12:07:49 EDT 2000:! ListenThread **** The WebLogic Server is
    no longer listening for connections.
    Tue Oct 03 12:07:49 EDT 2000:! ListenThread **** You should probably
    restart it.
    Tue Oct 03 12:07:49 EDT 2000:I WebLogicServer Server shutdown by system
    Tue Oct 03 12:07:50 EDT 2000:! SSLListenThread **** Unable to create
    server socket. Perhaps another process is using port: '7002'.
    java.net.BindException: Address in use: bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:390)
    at java.net.ServerSocket.init(ServerSocket.java:173)
    at java.net.ServerSocket.init(ServerSocket.java:124)
    at weblogic.security.SSL.SSLServerSocket.init(SSLServerSocket.java:96)
    at weblogic.security.SSL.SSLServerSocket.init(SSLServerSocket.java:56)
    at
    weblogic.t3.srvr.SSLListenThread.newServerSocket(SSLListenThread.java:472)
    at weblogic.t3.srvr.ListenThread.run(ListenThread.java, Compiled Code)

    DB:2.71:Unable To Create Server Socket 89

    Willie, did you ever find a solution to the problem? We have 4 developers on our project and I am the only one who is having this problem. It certainly is a pain to have to reboot my machine every time I have to restart the appserver. tia

  • RELEVANCY SCORE 2.70

    DB:2.70:How To Free A Port?? k7


    hi all,

    I have a problem with open ports when i wrote an ftp client application. I am closing the socket after transferring a file but the port on which i called bind() is not freed immediately after i called close(). it is TIME_WAITing for the ftp server. is there a way to close ports forcibly.
    i tried shutdown() that also is not working.

    thanks in advance
    ramana

    DB:2.70:How To Free A Port?? k7

    Try shutdown(3socket) or shutdown(3xnet)...

  • RELEVANCY SCORE 2.70

    DB:2.70:Running Multiple Instances Of Jboss 7 On A Windows 2008 Server pp



    I am having difficulties getting two instances of JBoss 7 to run on a Windows machine.

    I have the main instance listening on the default ports.

    I copied the entire folder structure to a new one called JBoss-AS-Web-Org2.

    I edited the standalone.xml file to add a port offset on the Org2 copy. It looks like this:

    Here is the management ports section:

    management-interfaces native-interface interface="management" port="29999"/ http-interface interface="management" port="29990"/ /management-interfaces/management

    Here is the port bindings section:

    /interface

    interface name="public"

    inet-address value="${jboss.bind.address:127.0.0.1}"/

    /interface

    /interfaces

    socket-binding-group name="standard-sockets" default-interface="public" port-offset="200"

    socket-binding name="http" port="8080"/

    socket-binding name="https" port="8443"/

    socket-binding name="jmx-connector-registry" port="1090" interface="management"/

    socket-binding name="jmx-connector-server" port="1091" interface="management"/

    socket-binding name="jndi" port="1099"/

    socket-binding name="osgi-http" port="8081" interface="management"/

    socket-binding name="remoting" port="4447"/

    socket-binding name="txn-recovery-environment" port="4712"/

    socket-binding name="txn-status-manager" port="4713"/

    /socket-binding-group

    /server

    When I start it up it still binds to the default ports and populates the logs in the original copy of JBoss.

    I have tried editing the set DIRNAME parm in the standalone.bat file with no luck. Here is what I tried:

    set DIRNAME=E:\JBoss-AS-Web-Org2\bin\

    I tried it with several iterations of the path with no luck.

    I tried this recommendation as well: http://community.jboss.org/wiki/MultipleInstancesOfJBossAS7OnTheSameMachine

    At the bottom of this thread a poster mentions adding the -Djboss.server.base.dir=instance1 parm. I tried it using my path with no luck. I tried it several ways with no luck.

    Any ideas?

    DB:2.70:Running Multiple Instances Of Jboss 7 On A Windows 2008 Server pp


    I've never had any problems running multiple instances without a JBOSS_HOME. In fact, I think it's mostly recommended not to have it set.

  • RELEVANCY SCORE 2.70

    DB:2.70:Windows Is Allowing To Bind To A Port Even If The Port Is In Time_Wait State. 87



    Hi All,

    I have written a simple client server program and I want my client programs to bind to a specific port range before connecting to the server.

    I am facing one problem here that for some port even though they are in TIME_WAIT state, windows is allowing me to bind.

    But when I am trying to connect to the server with that socket, I get ADDRESS ALREADY IN USE error.

    I am simply relying on bind(), as bind is successful here i am going ahead and trying to connect to the server.

    Same program if I build and run on linux i am not observing any issue.

    Is there any way I can check where the port is in use or not other than relying on bind?

    Is this a feature of windows, that it allows a port to be bind even though it is in TIME_WAIT state?

    Thanks,

    Sushil

    DB:2.70:Windows Is Allowing To Bind To A Port Even If The Port Is In Time_Wait State. 87


    Hi All,

    I have written a simple client server program and I want my client programs to bind to a specific port range before connecting to the server.

    I am facing one problem here that for some port even though they are in TIME_WAIT state, windows is allowing me to bind.

    But when I am trying to connect to the server with that socket, I get ADDRESS ALREADY IN USE error.

    I am simply relying on bind(), as bind is successful here i am going ahead and trying to connect to the server.

    Same program if I build and run on linux i am not observing any issue.

    Is there any way I can check where the port is in use or not other than relying on bind?

    Is this a feature of windows, that it allows a port to be bind even though it is in TIME_WAIT state?

    Thanks,

    Sushil

  • RELEVANCY SCORE 2.70

    DB:2.70:Cant Listen To Port 80 x3


    I am attempting to create a socket listener in a Windows application using a System.Net.Sockets.Socket but I could not bind to port 80 on my Windows 7 machine, I could bind to any other port without issue but attempting to bind to 80 always resulted in:an attempt was made to access a socket in a way forbidden by its access permissionsI discovered that IIS running locally locked up port 80 and that I had to move IIS to another port - you can read how to d os by going to http://www.ultimateproxylist.com/ChangingIIS.aspx The problem I still have - even after moving IIS off of Port 80 - is that no listener is actually working. I even grabbed the following code sample directly off the MSDN site and even IT does not work! I am on a Windows 7 machine - any ideas?!?
    // Create a listener.
    HttpListener listener = new HttpListener();

    // Add the prefixes.
    listener.Prefixes.Add(http://*:80/);
    listener.Start();
    Console.WriteLine(Listening...);
    // Note: The GetContext method blocks while waiting for a request.
    HttpListenerContext context = listener.GetContext();
    HttpListenerRequest request = context.Request;
    // Obtain a response object.
    HttpListenerResponse response = context.Response;
    // Construct a response.
    string responseString = HTMLBODY Hello world!/BODY/HTML;
    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
    // Get a response stream and write the response to it.
    response.ContentLength64 = buffer.Length;
    System.IO.Stream output = response.OutputStream;
    output.Write(buffer, 0, buffer.Length);
    // You must close the output stream.
    output.Close();
    listener.Stop();

    DB:2.70:Cant Listen To Port 80 x3

    The problem turned out to be with Skype - you need to go into Advanced Settings and tell Skype to NOT use Port 80.

  • RELEVANCY SCORE 2.70

    DB:2.70:2 Rpds On One Server c7


    Hi Gurus,
    i changed the port and started the preseentation services for hosting 2nd rpd on one server but gettting following error message

    An error occoured during execution of bind. an attempt was made to access a socket in a way forbidden by its access permission

    Thanks

    DB:2.70:2 Rpds On One Server c7

    Hi,
    Check this....http://rnm1978.wordpress.com/2009/08/25/multiple-rpds-on-one-server-part-1-the-bi-server/

    Regards,
    Srikanth

  • RELEVANCY SCORE 2.70

    DB:2.70:View Data Coming On The Port In Windows Server 2003 1x


    dears, advance thanks.
    I created one socket application which is recvig data from a gps tracking device through the port no 4444.
    everything is working perfect.now device is sending some picture information to server in hex format.but my socket application is not recvng that picture data in hex.can anybdy have idea y it is not getting in to my socket application?

    is it possible to monitor the coming data in to the port 4444 without the help of socket application?If possible how?
    i think tcp monitoring is possible.how can i do that?

    DB:2.70:View Data Coming On The Port In Windows Server 2003 1x

    Hi,
    Thanks for the post.
    Please first use TcpView tool to check if the socket application is listening on the Port 4444.
    http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
    Meanwhile, we could use Network Monitor to check the specific network traffic packets.
    Here is the KB article to teach you how to use Network Monitor to capture network traffic.
    http://support.microsoft.com/kb/812953
    Hope this helps.
    Miles

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • RELEVANCY SCORE 2.70

    DB:2.70:Connectexception While Connecting To Server 1d


    Hello, I got a client-server app - a chat, all goes OK when i try it at same computer, but when i start server on some computer and i try to connect to it from other computer i get ConnectException, (if i write invalid IP i get UnknowHostException) i tried more ports, also allowed them in firewall but still got that exception.

    Some code is here:

    this is server
    try {
    // open a non-blocking server socket channel
    sSockChan = ServerSocketChannel.open();
    sSockChan.configureBlocking(false);

    // bind to localhost on designated port
    InetAddress addr = InetAddress.getLocalHost();
    sSockChan.socket().bind(new InetSocketAddress(addr, PORT));

    // get a selector for multiplexing the client channels
    readSelector = Selector.open();
    myIP = addr + "";
    }
    catch (Exception e) {
    }still server
    now it is connecting clients
    try {
    SocketChannel clientChannel;
    // since sSockChan is non-blocking, this will return immediately
    // regardless of whether there is a connection available
    while ((clientChannel = sSockChan.accept()) != null) {
    addNewClient(clientChannel);
    System.out.println("server connecting");
    sendBroadcastMessage("login from: " + clientChannel.socket().getInetAddress(), clientChannel);
    sendMessage(clientChannel, "\n\nWelcome to ChatterBox, there are " +
    clients.size() + " users online.\n");
    sendMessage(clientChannel, "Press 'Quit' to exit.\n");
    }

    }
    catch (IOException ioe) {
    System.out.println("server IO exception");
    }
    catch (Exception e) {
    System.out.println("server exception");
    }and this is client which wants to connect server
    try {
    System.out.println("connecting");
    readSelector = Selector.open();
    InetAddress addr = InetAddress.getByName(host);
    channel = SocketChannel.open(new InetSocketAddress(addr, PORT));
    channel.configureBlocking(false);
    channel.register(readSelector, SelectionKey.OP_READ, new StringBuffer());
    System.out.println("conected");
    }
    catch (UnknownHostException uhe) {
    System.out.println("uhe");
    }
    catch (ConnectException ce) {
    System.out.println("ce");
    }
    catch (Exception e) {
    System.out.println("e");
    }Thank you for help.

    DB:2.70:Connectexception While Connecting To Server 1d

    If you have 2+ computer would you be so nice to try this, please?

    The code for client is here :
    Client.java
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Toolkit;
    import java.awt.event.*;

    import javax.swing.*;

    public class Client extends JFrame implements Runnable, ActionListener{
    static Client frame;
    static Container cont;
    static JTextArea chatArea, textArea;
    JButton sendButton, startButton, quit;
    JTextField IPfield, PORTfield, nickField;
    static boolean finished = false, connected = false;
    ChatterClient Cclient;
    public static String sendThis = "";
    public Client() {
    super("Chatter Box");
    System.out.println("in frameeee");

    Thread cs = new Thread(this);
    cs.start();


    }
    public static void main(String args[]) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }
    });

    }
    public void run() {

    while(!finished) {
    try {
    Thread.sleep(100);

    }
    catch(InterruptedException ie) { }
    }
    addComponentsToMainPane(cont);

    while(!connected) {
    try {
    Thread.sleep(100);

    }
    catch(InterruptedException ie) { }
    }
    while(true) {

    chatArea.append(Cclient.getChatText());
    try {
    Thread.sleep(100);

    }
    catch(InterruptedException ie) { }
    }

    }
    private static void createAndShowGUI() {
    // Create and set up the window.
    System.out.println("in create");
    JFrame.setDefaultLookAndFeelDecorated(true);

    if(frame == null) {

    frame = new Client();


    frame.setVisible(true);
    frame.getContentPane();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = screenSize.width;
    int height = screenSize.width;
    frame.setResizable(false);
    frame.setBounds(width / 4, height / 4, 1000, 640);
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.setVisible(true);
    frame.getContentPane();

    cont = frame.getContentPane();
    frame.pack();
    frame.setSize(1000, 640);

    finished = true;
    }

    }
    public void addComponentsToMainPane(Container Mainpane) {
    Mainpane.setLayout(null);

    nickField = new JTextField("your nickname");
    IPfield = new JTextField("write here IP");
    PORTfield = new JTextField("write here PORT");
    sendButton = new JButton("Send");
    startButton = new JButton("Start!");
    quit = new JButton("Quit!");

    sendButton.setEnabled(false);
    sendButton.addActionListener(this);
    startButton.addActionListener(this);
    quit.addActionListener(this);

    textArea = new JTextArea();

    textArea.setEnabled(false);
    textArea.setEditable(true);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    chatArea = new JTextArea("");
    chatArea.setFont(new Font("Serif", Font.PLAIN , 20));

    chatArea.setEnabled(false);
    chatArea.setEditable(false);
    chatArea.setLineWrap(true);
    chatArea.setWrapStyleWord(true);

    JScrollPane areaScrollPane = new JScrollPane(chatArea);
    areaScrollPane.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JScrollPane areaScrollPane2 = new JScrollPane(textArea);
    areaScrollPane2.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    Mainpane.add(areaScrollPane);
    Mainpane.add(areaScrollPane2);
    Mainpane.add(sendButton);
    Mainpane.add(startButton);
    Mainpane.add(quit);
    Mainpane.add(IPfield);
    Mainpane.add(PORTfield);
    Mainpane.add(nickField);

    areaScrollPane.setBounds(5, 5, 980, 490);
    areaScrollPane2.setBounds(5, 500, 800, 100);
    startButton.setBounds(810, 530, 70, 30);
    sendButton.setBounds(810, 500, 70, 30);
    quit.setBounds(810, 560, 70, 30);
    IPfield.setBounds(885, 500, 100, 30);
    PORTfield.setBounds(885, 530, 100, 30);
    nickField.setBounds(885, 560, 100, 30);

    frame.pack();
    frame.setSize(1000, 640);

    }

    public void actionPerformed(ActionEvent e) {
    if(e.getSource() == startButton) {
    startButton.setEnabled(false);
    IPfield.setEnabled(false);
    PORTfield.setEnabled(false);
    nickField.setEnabled(false);
    sendButton.setEnabled(true);
    chatArea.setEnabled(true);
    textArea.setEnabled(true);
    try {
    Cclient.PORT = Integer.parseInt(PORTfield.getText().trim());
    }
    catch(NumberFormatException nfe) {
    nfe.printStackTrace();
    }
    Cclient = new ChatterClient(IPfield.getText(), true);

    connected = true;
    }
    if(e.getSource() == sendButton) {
    sendThis = textArea.getText();
    Cclient.sendWhat(nickField.getText() + " :" + sendThis);
    textArea.setText("");
    }
    if(e.getSource() == quit) {
    try {
    sendThis = textArea.getText();
    Cclient.sendWhat("quit");
    textArea.setText("");
    }
    catch(NullPointerException ie) { }
    try{
    Thread.sleep(1000);
    }
    catch(InterruptedException ie) { }
    System.exit(0);
    }
    }
    }ChatterClient.java
    import java.nio.*;
    import java.nio.charset.*;
    import java.nio.channels.*;
    import java.util.*;
    import java.net.*;
    import java.io.*;

    public class ChatterClient extends Thread {
    private static final int BUFFER_SIZE = 255;
    private static final long CHANNEL_WRITE_SLEEP = 10L;
    public static int PORT = 10997;

    public static String sendString = "";
    private ByteBuffer writeBuffer;
    private ByteBuffer readBuffer;
    private boolean running;
    private SocketChannel channel;
    private String host = null;
    private Selector readSelector;
    private CharsetDecoder asciiDecoder;
    private InputThread it;
    String chatString = "";
    public ArrayList list;
    public ChatterClient cc2;

    public ChatterClient(String args, boolean b) {
    this.host = args;
    cc2 = new ChatterClient(host);
    cc2.start();
    }
    public ChatterClient(String host) {
    list = new ArrayList();
    this.host = host;
    System.out.println("in ctclient (host" + host + " port " + PORT);
    writeBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
    readBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
    asciiDecoder = Charset.forName( "US-ASCII").newDecoder();;
    }

    public void run() {

    while(host == null) {
    System.out.println("host is null");
    try {
    Thread.sleep(200);
    }
    catch(InterruptedException ie) { ie.printStackTrace();}
    }
    connect(host);
    it = new InputThread(this);
    it.start();

    running = true;
    while (running) {
    readIncomingMessages();

    try {
    Thread.sleep(50);
    }
    catch (InterruptedException ie) {
    ie.printStackTrace();
    }
    }
    System.err.println("run ended");
    }

    private void connect(String hostname) {
    try {
    System.out.println("connecting");
    readSelector = Selector.open();
    InetAddress addr = InetAddress.getByName(host);
    channel = SocketChannel.open(new InetSocketAddress(addr, PORT));
    channel.configureBlocking(false);
    channel.register(readSelector, SelectionKey.OP_READ, new StringBuffer());
    System.out.println("conected");
    }
    catch (UnknownHostException uhe) {
    uhe.printStackTrace();
    System.out.println("uhe");
    }
    catch (ConnectException ce) {
    ce.printStackTrace();
    System.out.println("ce");
    }
    catch (Exception e) {
    e.printStackTrace();
    System.out.println("e");
    }
    }

    private void readIncomingMessages() {
    // check for incoming mesgs
    try {
    // non-blocking select, returns immediately regardless of how many keys are ready
    readSelector.selectNow();
    // fetch the keys
    Set readyKeys = readSelector.selectedKeys();

    // run through the keys and process
    Iterator i = readyKeys.iterator();
    while (i.hasNext()) {
    SelectionKey key = (SelectionKey) i.next();
    i.remove();
    SocketChannel channel = (SocketChannel) key.channel();
    readBuffer.clear();

    // read from the channel into our buffer
    long nbytes = channel.read(readBuffer);

    // check for end-of-stream
    if (nbytes == -1) {
    System.out.println("disconnected from server: end-of-stream");
    channel.close();
    shutdown();
    it.shutdown();
    }
    else {
    // grab the StringBuffer we stored as the attachment
    StringBuffer sb = (StringBuffer)key.attachment();

    // use a CharsetDecoder to turn those bytes into a string
    // and append to our StringBuffer
    readBuffer.flip( );
    String str = asciiDecoder.decode( readBuffer).toString( );
    sb.append( str );
    readBuffer.clear( );

    // check for a full line and write to STDOUT
    String line = sb.toString();
    String string123 = "\n" + line;
    if ((line.indexOf("\n") != -1) || (line.indexOf("\r") != -1)) {
    sb.delete(0,sb.length());

    list.add("\n" + line);
    System.out.print(list.get(0) + "in inputThread");

    }

    }
    }
    }
    catch (IOException ioe) {
    ioe.printStackTrace();
    }
    catch (Exception e) {
    e.printStackTrace();
    System.out.println("ex");
    }
    }
    public String getChatText() {

    try {
    if(cc2.list.size() != 0) {
    String s = (String)cc2.list.get(0);
    cc2.list.remove(0);
    return s;
    }

    }
    catch(NullPointerException npe) {
    System.err.println("got nullpointer");
    return "";
    }
    catch(NoSuchElementException ne) {
    System.out.println("neeeeeee");
    return "";
    }
    return "";
    }
    public void sendMessage(String mesg) {
    list.add(" " + mesg);
    prepWriteBuffer(mesg);
    channelWrite(channel, writeBuffer);
    }

    private void prepWriteBuffer(String mesg) {
    // fills the buffer from the given string
    // and prepares it for a channel write

    writeBuffer.clear();
    writeBuffer.put(mesg.getBytes());
    writeBuffer.putChar('\n');
    writeBuffer.flip();
    }

    private void channelWrite(SocketChannel channel, ByteBuffer writeBuffer) {
    long nbytes = 0;
    long toWrite = writeBuffer.remaining();

    // loop on the channel.write() call since it will not necessarily
    // write all bytes in one shot
    try {
    while (nbytes != toWrite) {
    nbytes += channel.write(writeBuffer);

    try {
    Thread.sleep(CHANNEL_WRITE_SLEEP);
    }
    catch (InterruptedException e) {
    e.printStackTrace();}

    }
    }
    catch (ClosedChannelException cce) {
    cce.printStackTrace();
    }
    catch (Exception e) {
    e.printStackTrace();
    }

    // get ready for another write if needed
    writeBuffer.rewind();
    }

    public void shutdown() {
    running = false;
    interrupt();
    }
    public String sendThis() {
    return sendString;
    }
    public void sendWhat(String s) {
    sendString = s;

    }
    /**
    * InputThread reads user input from STDIN
    */
    class InputThread extends Thread {
    private ChatterClient cc;
    private boolean running;
    public InputThread(ChatterClient cc) {
    this.cc = cc;
    }

    public void run() {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    running = true;
    while (running) {
    try {
    String s;
    System.out.flush();
    s = sendThis();
    if (s.length() 0){
    cc.sendMessage(s + "\n");
    System.out.println(s);
    sendWhat("");
    }
    if (s.equals("quit")) {
    running = false;

    }

    }
    catch (Exception e) {
    e.printStackTrace();
    running = false;
    }
    try {
    Thread.sleep(100);
    }
    catch(InterruptedException ie) { ie.printStackTrace();}
    }
    cc.shutdown();
    }
    public void shutdown() {
    running = false;
    interrupt();
    }
    }
    }and finally ChatterServer.java
    import java.nio.*;
    import java.nio.channels.*;
    import java.nio.charset.*;
    import java.util.*;
    import java.net.*;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.*;
    import java.io.*;

    import javax.swing.*;

    public class ChatterServer extends JFrame implements Runnable, ActionListener{

    private static final long serialVersionUID = 1L;
    private static final int BUFFER_SIZE = 255;
    private static final long CHANNEL_WRITE_SLEEP = 10L;
    private int PORT = 10997;

    private ServerSocketChannel sSockChan;
    private Selector acceptSelector;
    private Selector readSelector;
    private SelectionKey selectKey;
    private boolean running;
    private LinkedList clients;
    private ByteBuffer readBuffer;
    private ByteBuffer writeBuffer;
    private CharsetDecoder asciiDecoder;
    static ChatterServer frame;
    static boolean finished = false;
    static boolean started = false;
    JTextField portField;
    JButton startButton;
    JLabel portLabel;
    JLabel IPLabel;
    static Thread cs;
    static Container cont;
    String myIP = null;
    public static void main(String args[]) {

    //BasicConfigurator.configure();
    System.out.println("in main");
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();

    }
    });

    }
    private static void createAndShowGUI() {
    // Create and set up the window.
    System.out.println("in create");
    JFrame.setDefaultLookAndFeelDecorated(true);

    if(frame == null) {

    frame = new ChatterServer();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setVisible(true);
    frame.getContentPane();

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = screenSize.width;
    int height = screenSize.width;
    frame.setResizable(false);
    frame.setBounds(width / 4, height / 4, 300, 150);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setVisible(true);
    frame.getContentPane();

    cont = frame.getContentPane();

    frame.pack();
    frame.setSize(300, 150);

    finished = true;
    }

    }
    public ChatterServer() {
    super("Chatter Server");
    System.out.println("in frame");

    clients = new LinkedList();
    readBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
    writeBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
    asciiDecoder = Charset.forName( "US-ASCII").newDecoder();;

    Thread cs = new Thread(this);
    cs.start();

    }
    public void addComponentsToMainPane(Container Mainpane) {

    if(myIP == null) {
    Mainpane.setLayout(null);
    portField = new JTextField();
    portLabel = new JLabel("Port:");

    startButton = new JButton("Start!");
    startButton.addActionListener(this);
    Mainpane.add(portField);
    Mainpane.add(startButton);
    Mainpane.add(portLabel);

    portField.setBounds(100, 20, 50, 20);
    startButton.setBounds(90, 50, 70, 20);
    portLabel.setBounds(110, 0, 50, 20);
    }
    else {
    IPLabel = new JLabel(myIP);
    Mainpane.add(IPLabel);
    IPLabel.setBounds(10, 70, 200, 20);
    }

    }

    private void initServerSocket() {
    try {
    // open a non-blocking server socket channel
    sSockChan = ServerSocketChannel.open();
    sSockChan.configureBlocking(false);

    // bind to localhost on designated port
    InetAddress addr = InetAddress.getLocalHost();
    sSockChan.socket().bind(new InetSocketAddress(addr, PORT));

    // get a selector for multiplexing the client channels
    readSelector = Selector.open();
    myIP = addr + "";
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }

    public void run() {

    while(!finished) {
    try {
    Thread.sleep(100);
    }
    catch (InterruptedException ie) {
    ie.printStackTrace();
    }
    }
    addComponentsToMainPane(cont);
    System.out.println("in run");
    while(!started) {
    try {
    Thread.sleep(100);
    }
    catch (InterruptedException ie) {
    ie.printStackTrace();
    }

    }
    initServerSocket();
    addComponentsToMainPane(cont);
    running = true;

    // block while we wait for a client to connect
    while (running) {
    // check for new client connections
    acceptNewConnections();

    // check for incoming messages
    readIncomingMessages();

    // sleep a bit
    try {
    Thread.sleep(100);
    }
    catch (InterruptedException ie) {
    ie.printStackTrace();
    }
    }
    }

    private void acceptNewConnections() {
    try {
    SocketChannel clientChannel;
    // since sSockChan is non-blocking, this will return immediately
    // regardless of whether there is a connection available
    while ((clientChannel = sSockChan.accept()) != null) {
    addNewClient(clientChannel);
    System.out.println("server connecting");
    sendBroadcastMessage("login from: " + clientChannel.socket().getInetAddress(), clientChannel);
    sendMessage(clientChannel, "\n\nWelcome to ChatterBox, there are " +
    clients.size() + " users online.\n");
    sendMessage(clientChannel, "Press 'Quit' to exit.\n");
    }

    }
    catch (IOException ioe) {
    System.out.println("server IO exception");
    ioe.printStackTrace();
    }
    catch (Exception e) {
    System.out.println("server exception");
    e.printStackTrace();
    }
    }

    private void readIncomingMessages() {
    try {
    // non-blocking select, returns immediately regardless of how many keys are ready
    readSelector.selectNow();

    // fetch the keys
    Set readyKeys = readSelector.selectedKeys();

    // run through the keys and process
    Iterator i = readyKeys.iterator();
    while (i.hasNext()) {
    SelectionKey key = (SelectionKey) i.next();
    i.remove();
    SocketChannel channel = (SocketChannel) key.channel();
    readBuffer.clear();

    // read from the channel into our buffer
    long nbytes = channel.read(readBuffer);

    // check for end-of-stream
    if (nbytes == -1) {
    channel.close();
    clients.remove(channel);
    sendBroadcastMessage("logout: " + channel.socket().getInetAddress() , channel);
    }
    else {
    // grab the StringBuffer we stored as the attachment
    StringBuffer sb = (StringBuffer)key.attachment();

    // use a CharsetDecoder to turn those bytes into a string
    // and append to our StringBuffer
    readBuffer.flip( );
    String str = asciiDecoder.decode( readBuffer).toString( );
    readBuffer.clear( );
    sb.append( str);

    // check for a full line
    String line = sb.toString();
    if ((line.indexOf("\n") != -1) || (line.indexOf("\r") != -1)) {
    line = line.trim();
    if (line.startsWith("quit")) {
    // client is quitting, close their channel, remove them from the list and notify all other clients
    channel.close();
    clients.remove(channel);
    sendBroadcastMessage("logout: " + channel.socket().getInetAddress(), channel);
    System.out.println(line);
    }
    else {
    // got one, send it to all clients
    sendBroadcastMessage(/*channel.socket().getInetAddress() + ": " */ line, channel);
    System.out.println("in server" + line);
    sb.delete(0,sb.length());
    }
    }
    }

    }
    }
    catch (IOException ioe) {
    ioe.printStackTrace();
    }
    catch (Exception e) {
    e.printStackTrace();
    }

    }

    private void addNewClient(SocketChannel chan) {
    // add to our list
    clients.add(chan);

    // register the channel with the selector
    // store a new StringBuffer as the Key's attachment for holding partially read messages
    try {
    chan.configureBlocking( false);
    SelectionKey readKey = chan.register(readSelector, SelectionKey.OP_READ, new StringBuffer());
    }
    catch (ClosedChannelException cce) {
    cce.printStackTrace();
    }
    catch (IOException ioe) {
    ioe.printStackTrace();
    }
    }

    private void sendMessage(SocketChannel channel, String mesg) {
    prepWriteBuffer(mesg);
    channelWrite(channel, writeBuffer);
    }

    private void sendBroadcastMessage(String mesg, SocketChannel from) {
    prepWriteBuffer(mesg);
    Iterator i = clients.iterator();
    while (i.hasNext()) {
    SocketChannel channel = (SocketChannel)i.next();
    if (channel != from)
    channelWrite(channel, writeBuffer);
    }
    }

    private void prepWriteBuffer(String mesg) {
    // fills the buffer from the given string
    // and prepares it for a channel write
    writeBuffer.clear();
    writeBuffer.put(mesg.getBytes());
    writeBuffer.putChar('\n');
    writeBuffer.flip();
    }

    private void channelWrite(SocketChannel channel, ByteBuffer writeBuffer) {
    long nbytes = 0;
    long toWrite = writeBuffer.remaining();

    // loop on the channel.write() call since it will not necessarily
    // write all bytes in one shot
    try {
    while (nbytes != toWrite) {
    nbytes += channel.write(writeBuffer);

    try {
    Thread.sleep(CHANNEL_WRITE_SLEEP);
    }
    catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }
    catch (ClosedChannelException cce) {
    cce.printStackTrace();
    }
    catch (Exception e) {
    e.printStackTrace();
    }

    // get ready for another write if needed
    writeBuffer.rewind();
    }

    public void actionPerformed(ActionEvent e) {
    if(e.getSource() == startButton) {
    System.out.println("kk");
    startButton.setEnabled(false);
    int i = -1;
    try {
    i = Integer.parseInt(portField.getText().trim());
    }
    catch(NumberFormatException n) {
    n.printStackTrace();
    }
    PORT = i;
    System.out.println(i);
    if(PORT != -1) {
    started = true;

    }
    else {
    startButton.setEnabled(true);
    }

    }
    }

    }Thanks for help.

  • RELEVANCY SCORE 2.70

    DB:2.70:Socket Bind Throws Socket Closed m3


    I am trying to setup a socket when I can specify the bind address and have it timeout if it cannot connect. The only way I can see in doing that is creating an open socket

    private Socket checker = new Socket();Setting some things -

    checker.setSoTimeout(2000);
    checker.setKeepAlive(true);Specifying the bind to address: (addr is one of the local machine addresses, the machine has several. It can pick any port)

    InetSocketAddress adr = new InetSocketAddress(addr,0);
    checker.bind(adr);Then connect (server is the address and port of the server socket)

    checker.connect(server,2000);But it never gets that far, then bind returns a SocketException that the socket is closed, of course it is closed because I have not opened it yet and I am trying to bind it first. If i create and bind the socket all at once I cannot set a timeout. i.e Socket(remtoeaddr, remote port, localaddr, localport); I cannot set the timeout if the server is not within reach.

    DB:2.70:Socket Bind Throws Socket Closed m3

    So as I read it, isConnected() and isClosed() only reports back if the socket has had a connect() or a close() issued on it.That's what he said. Part of it is also what I said.
    So the only way to actually detect if the socket is valid and actually connected is to do a write() and it does not throw an exceptionThat's what I said.
    and the read() will block forever (Even if the socket is no longer able to reach the far end)The socket doesn't have to 'reach the far end' for a read. The far end has to reach us. That's why a read won't unblock except for a timeout. There is no incoming protocol to tell it anything.
    What happens during a read() if the thread that it is blocking is interrupted by another thread that does an interrupt() on it?It's unspecified for Sockets and in practice nothing happens. For SocketChannels it causes the channel to be closed and a ClosedByInterruptException to be thrown.

    Use a read timeout. There may be circumstances when a network program shouldn't set a read timeout but I've never seen one.

    As for your solution, you shouldn't need all that. Just have a thread that tries to connect to the server every 5 minutes or whatever. If it succeeds, there you go. If it doesn't, bad luck. You shouldn't need to worry about interfaces and binding and ups and downs.

  • RELEVANCY SCORE 2.70

    DB:2.70:Applications Using A Dhcp Configured Interface mk



    If I have server applications running that are listening

    // Start Server srvr = socket(PF_INET, SOCK_STREAM, 0); /* Bind the socket to the port */ any.sin_family = AF_INET; any.sin_port = 80; any.sin_addr.s_addr = INADDR_ANY; bind(srvr, any, sizeof(any)); listen(srvr, 0);

    Will this server continue to run properly if the interface is moved from one LAN to another and the IP address assigned by DHCP changes?

    What is the right way to re-activate DHCP when the cable is re-interted?

    tom

    DB:2.70:Applications Using A Dhcp Configured Interface mk


    FYI I ended up polling the link state with
    ipcfg_get_link_active(IPCFG_default_enet_device)

    and when the link went away, I would unbind the old IP and reenable DHCP to get the new IP

    tom

  • RELEVANCY SCORE 2.70

    DB:2.70:Windows 7 Socket Bind Behavior Difference From Xp, With Reuse Address Socket Option (Wsaeacces 10013 Error) ka


    I have two processes that are both listening to UDP packets and can run on the same PC. One process binds a socket to one NIC address with port 18246. The other process has two Socket objects, one for sending on port 18246 and one for listening
    on port 18246. Both of these sockets are created, have the SO_REUSEADDR socket option set. Bind is called for a single IP Endpoint for a common local NIC address, but a different one than used by the above app.
    Under Windows XP and server 2003, both processes can bind regardless of order of startup.
    Under Windows 7, if the process with only one socket starts first, the second process fails with WSAEACCES 10013 error with the second socket bind.
    I wrote a sample C# app with the following method that fails when running under Windows 7 x86 and x64. The above failure occurs when the sockets are in separate processes, but a single process using the same socket interaction also fails. The
    below method is called with two IPV4 addresses that are assigned to local Network adapters on the PC.

    using

    System.Net;

    using

    System.Net.Sockets;

    private
    void
    TestMultiplePortBind(string
    ipAddr1, string
    ipAddr2)

    Socket
    s = new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    IPEndPoint
    ipEndPt = new
    IPEndPoint(IPAddress.Parse(ipAddr1),
    18246);

    new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    s.SetSocketOption(

    SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress,
    1);

    ipEndPt =

    new
    IPEndPoint(IPAddress.Parse(ipAddr2),
    18246);

    new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    s.SetSocketOption(

    SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress,
    1);

    ipEndPt =

    new
    IPEndPoint(IPAddress.Parse(ipAddr2),
    18246);

    I have opened an incident case for this question but wanted to update this posting regarding two points:
    - The behavior change seen in Windows 7 is also present in Windows Server 2003. I was in error in my previous post. The behavior change is part of the enhanced socket security added to Windows Server 2003, Vista and Windows 7 (and I assume Server
    2008).
    http://blogs.msdn.com/b/wndp/archive/2005/08/03/anthony-jones.aspx
    There is still an open question as to the above scenario being an unintended consiquence of the enhanced socket security. I believe it to be unintended because the above code will not result in an 10013 error if the socket binds are ordered differently.
    If the first socket creation/bind is moved the be the last, there are no errors. In my case that means the order of process startup yields different results. In my case, each process has their own unique network address to bind a known UDP socket.
    It should also be noted that the above test code would be better if it had a try/finally where the finally calls each created socket's Close method.

    s.Bind(ipEndPt);
    }

    I can avoid the WSAEACCES error by setting the reuse address option to the first socket created, but I don't want to allow reuse of that particular socket in my application as it will effect which process receives unicast UDP traffic. I need it to
    fail if another process is using that port/address combination.
    Is this a bug in Windows 7?

    s.Bind(ipEndPt);

    s =

    s.Bind(ipEndPt);

    s =

    {

    DB:2.70:Windows 7 Socket Bind Behavior Difference From Xp, With Reuse Address Socket Option (Wsaeacces 10013 Error) ka

    I have two processes that are both listening to UDP packets and can run on the same PC. One process binds a socket to one NIC address with port 18246. The other process has two Socket objects, one for sending on port 18246 and one for listening
    on port 18246. Both of these sockets are created, have the SO_REUSEADDR socket option set. Bind is called for a single IP Endpoint for a common local NIC address, but a different one than used by the above app.
    Under Windows XP and server 2003, both processes can bind regardless of order of startup.
    Under Windows 7, if the process with only one socket starts first, the second process fails with WSAEACCES 10013 error with the second socket bind.
    I wrote a sample C# app with the following method that fails when running under Windows 7 x86 and x64. The above failure occurs when the sockets are in separate processes, but a single process using the same socket interaction also fails. The
    below method is called with two IPV4 addresses that are assigned to local Network adapters on the PC.

    using

    System.Net;

    using

    System.Net.Sockets;

    private
    void
    TestMultiplePortBind(string
    ipAddr1, string
    ipAddr2)

    Socket
    s = new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    IPEndPoint
    ipEndPt = new
    IPEndPoint(IPAddress.Parse(ipAddr1),
    18246);

    new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    s.SetSocketOption(

    SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress,
    1);

    ipEndPt =

    new
    IPEndPoint(IPAddress.Parse(ipAddr2),
    18246);

    new
    Socket(AddressFamily.InterNetwork,
    SocketType.Dgram,
    ProtocolType.Udp);

    s.SetSocketOption(

    SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress,
    1);

    ipEndPt =

    new
    IPEndPoint(IPAddress.Parse(ipAddr2),
    18246);

    I have opened an incident case for this question but wanted to update this posting regarding two points:
    - The behavior change seen in Windows 7 is also present in Windows Server 2003. I was in error in my previous post. The behavior change is part of the enhanced socket security added to Windows Server 2003, Vista and Windows 7 (and I assume Server
    2008).
    http://blogs.msdn.com/b/wndp/archive/2005/08/03/anthony-jones.aspx
    There is still an open question as to the above scenario being an unintended consiquence of the enhanced socket security. I believe it to be unintended because the above code will not result in an 10013 error if the socket binds are ordered differently.
    If the first socket creation/bind is moved the be the last, there are no errors. In my case that means the order of process startup yields different results. In my case, each process has their own unique network address to bind a known UDP socket.
    It should also be noted that the above test code would be better if it had a try/finally where the finally calls each created socket's Close method.

    s.Bind(ipEndPt);
    }

    I can avoid the WSAEACCES error by setting the reuse address option to the first socket created, but I don't want to allow reuse of that particular socket in my application as it will effect which process receives unicast UDP traffic. I need it to
    fail if another process is using that port/address combination.
    Is this a bug in Windows 7?

    s.Bind(ipEndPt);

    s =

    s.Bind(ipEndPt);

    s =

    {

  • RELEVANCY SCORE 2.70

    DB:2.70:Tcpserver - Call To Accept Fails - Why?? z1


    What have I done wrong? Is it something in the settings that I missed?
    The code is from the book Network Programming fr Microsoft Windows 2nd ed.
    The following code are suposed to be a very simple TCP server.
    At the line
    if ((NewConnection = accept(ListeningSocket, (SOCKADDR *) ClientAddr, ClientAddrLen)) == INVALID_SOCKET)
    the accept return a INVALID_SOCKET. So the program just exits without waiting for any connections from the client.
    I did print outsome date from the ClientAddr and it says: Client port = 52428, client address = 204.204.204.204. Probably just garbage in memmory.
    I code in Visual Studio 2010 and under XP.

    // tcpserver.cpp

    #include winsock2.h
    #include stdio.h

    void main(void)
    {
    WSADATA wsaData;
    SOCKET ListeningSocket;
    SOCKET NewConnection;
    SOCKADDR_IN ServerAddr;
    SOCKADDR_IN ClientAddr;
    int ClientAddrLen;
    int Port = 5150;
    int Ret;
    char DataBuffer[1024];

    if ((Ret = WSAStartup(MAKEWORD(2,2), wsaData)) != 0)
    {
    printf(WSAStartup failed with error %d\n, Ret);
    return;
    }

    if ((ListeningSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))
    == INVALID_SOCKET)
    {
    printf(socket failed with error %d\n, WSAGetLastError());
    WSACleanup();
    return;
    }

    ServerAddr.sin_family = AF_INET;
    ServerAddr.sin_port = htons(Port);
    ServerAddr.sin_addr.s_addr = htonl(INADDR_ANY);

    if (bind(ListeningSocket, (SOCKADDR *)ServerAddr, sizeof(ServerAddr))
    == SOCKET_ERROR)
    {
    printf(bind failed with error %d\n, WSAGetLastError());
    closesocket(ListeningSocket);
    WSACleanup();
    return;
    }

    printf(Listening socket before listen %d\n, ListeningSocket);

    if (listen(ListeningSocket, 5) == SOCKET_ERROR)
    {
    printf(listen failed with error %d\n, WSAGetLastError());
    closesocket(ListeningSocket);
    WSACleanup();
    return;
    }

    printf(We are awaiting a connection on port %d.\n, Port);

    if ((NewConnection = accept(ListeningSocket, (SOCKADDR *) ClientAddr,
    ClientAddrLen)) == INVALID_SOCKET)
    {
    printf(accept failed with error %d\n, WSAGetLastError());
    closesocket(ListeningSocket);
    WSACleanup();
    return;
    }

    printf(We successfully got a connection from %s:%d.\n,
    inet_ntoa(ClientAddr.sin_addr), ntohs(ClientAddr.sin_port));

    closesocket(ListeningSocket);

    printf(We are waiting to receive data...\n);

    if ((Ret = recv(NewConnection, DataBuffer, sizeof(DataBuffer), 0))
    == SOCKET_ERROR)
    {
    printf(recv failed with error %d\n, WSAGetLastError());
    closesocket(NewConnection);
    WSACleanup();
    return;
    }

    printf(We successfully received %d byte(s).\n, Ret);

    printf(We are now going to close the client connection.\n);

    closesocket(NewConnection);

    WSACleanup();
    }

    DB:2.70:Tcpserver - Call To Accept Fails - Why?? z1

    Oops, sorry, You are right, too quick...
    Rob
    www.robtso.nl