aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes ServerSocket to SSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "ServerSocket to SSL" Watch "ServerSocket to SSL" New topic
Author

ServerSocket to SSL

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I can change

to

and it will work fine?

I've never used SSL stuff before and just want to make sure I have it right before I go through with it. I have made a huge IM chat program and am trying to make it better (and learn new things). Do I have to change any of my other code? Here is my whole server code (modified to cut down on code lines and hide certain things I don't want people to know...


Would I have to change my client code too (change it to using SSL)?
Thanks,
John Price aka cc11rocks


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

That code looks alright to me. And yes, you need to start using SSLSocket in the client as well, using SSLSocketFactory. Fortunately, nothing needs to change in both the client and the server except the lines that create the ServerSocket (server) and Socket (client). You can even keep the reference types as ServerSocket and Socket, as SSLServerSocket and SSLSocket provide no extra methods you need. That way you don't even need the cast to SSLServerSocket you have.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServerSocket to SSL
 
Similar Threads
Head First Java Chapter 15 Questiion
What type should i cast?
85 line program...wondering if it's possible to do in Applets
Help with Chat software
Client disconnected from server after about 10 minutes of inactivity