Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Communicating with Servers prob (Java)

Options
  • 04-12-2002 4:59pm
    #1
    Registered Users Posts: 68,317 ✭✭✭✭


    Right, I'm just fiddling around with some code, Sockets and whatnot, and basic debugging has shown me that everything works, except that the Server doesn't know when I've finished transmitting.

    So for example, say I was communicating with a POP server, I send it the String "USER seamus". Then nothing. I get no response from the server at all. And the server is coconnected with me because I get the "+OK server.blah.blah POP3 ready". I know when I do this myself at a terminal, the server does nothing until I hit Carriage Return.

    But appending a "\n" to the String does nothing. And the BufferedWriter.newLine() method does nothing either.

    I'm sure this is very simple. Do I just have to append some byte to the String?


Comments

  • Registered Users Posts: 1,328 ✭✭✭Sev


    I dont know anything about socket functions in Java... but try a "\r\n".


  • Registered Users Posts: 1,186 ✭✭✭davej


    Have you tried "\r\n" ? ie carriage return - linefeed


  • Closed Accounts Posts: 285 ✭✭marauder


    Its been a long time, but I seem to recall needing to do a buffer flush after each string was sent to ensure it is acutally sent rather than cached...


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    i bet i'm totally off the mark here but would the unicode for return work?


  • Registered Users Posts: 2,010 ✭✭✭Dr_Teeth


    Last time I was doing socket stuff like this was in perl. I did something like:
    print $socket "$username".chr(250).chr(4);
    

    Dunno if that's helpful to you seamus. :)

    Teeth.


  • Advertisement
  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Cheers all, marauder was right. You have to send the line (with the newline char) and then flush the Stream.

    Danka


Advertisement