SocketChannel problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • green
    New Member
    • Oct 2007
    • 7

    SocketChannel problem

    dear all ,
    I'm trying to write a socket program . using the SocketChannel.. .
    but I don't receive any thing from the server. why ???????

    this my code


    Code:
            address = new InetSocketAddress("***.***.**.**",**** );
            channel = SocketChannel.open(address);              
            byte[] b = getAuthenticationLoginString("***","********");
            ByteBuffer bbuf = ByteBuffer.allocate(b.length);
            bbuf.put(b);
            channel.write(bbuf);        
            channel.configureBlocking(false);
            
            Thread.sleep(2000);        
            ByteBuffer responsebuf = ByteBuffer.allocateDirect(1024);
            int n = channel.read(responsebuf);
            System.out.println(n);
            if(n < 0 )
                channel.close();
            else
            {
                byte[] v = new byte[1024];
                responsebuf.get(v);
                String returnString = decryptReturnedResponse(v);
            }
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Does it work when you use an ordinary Socket that you bind to your server?

    kind regards,

    Jos

    Comment

    • green
      New Member
      • Oct 2007
      • 7

      #3
      Originally posted by JosAH
      Does it work when you use an ordinary Socket that you bind to your server?

      kind regards,

      Jos

      No, It does not work

      I have a big problem withe the ordinary socket

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by green
        No, It does not work

        I have a big problem withe the ordinary socket
        So if you try to connect an ordinary socket to your server it fails?

        kind regards,

        Jos

        Comment

        Working...