mailSocket = new Socket("localhost",8084); //tried with a lot of other port
numbers too
and i keep getting the exception:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at mail.Server.<init>(Server.java:28)
at mail.Server.main(Server.java:11)
what do i need to do to be able to successfully create a socket?
thanks
hilz
you need the port to be open (i.e. a ServerSocket accepting connections on
that port) ....
andreas
[...]
> what do i need to do to be able to successfully create a socket?
> thanks
The Socket constructor actually connects to the remote host and port
you specify. If nobody's listening, the constructor will fail as
you've discovered.
Either connect to a well known service (for example port 80 on most
web servers), or write a second program that opens a ServerSocket to
accept incoming connections on a port you've chosen.
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
appologies!
there is nothing here to see!
move along!