Results 1 to 3 of 3
- 01-03-2008, 10:38 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 14
- Rep Power
- 0
- 01-03-2008, 12:21 PM #2
Run one.Server first followed by one.Client should print 5.Java Code:package one; import java.io.DataInputStream; import java.net.ServerSocket; import java.net.Socket; public class Server { public static void main(String[] args) throws Exception{ ServerSocket serverSocket = new ServerSocket(8080); Socket socket = serverSocket.accept(); DataInputStream din = new DataInputStream(socket.getInputStream()); System.out.println(din.readInt()); socket.close() } } package one; import java.io.DataOutputStream; import java.net.Socket; public class Client { public static void main(String[] args) throws Exception { Socket socket = new Socket("localhost" , 8080 ); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeInt(5); socket.close(); } }dont worry newbie, we got you covered.
- 01-03-2008, 01:03 PM #3
Member
- Join Date
- Jan 2008
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
send file via client - server model
By spasavvas in forum NetworkingReplies: 15Last Post: 08-13-2010, 11:45 AM -
Server socket - send image to client
By Hinty in forum NetworkingReplies: 2Last Post: 03-14-2009, 07:39 AM -
A Client to Send SMTP Mail
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:06 PM -
how to send .jar files client to server
By gobinathm in forum NetworkingReplies: 1Last Post: 12-25-2007, 04:05 AM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks