Specifications
Sun Services
Java™ Programming Language
Module 15, slide 9 of 12
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Minimal TCP/IP Server
14
15 // Run the listen/accept loop forever
16 while (true) {
17 try {
18 // Wait here and listen for a connection
19 Socket s1 = s.accept();
20
21 // Get output stream associated with the socket
22 OutputStream s1out = s1.getOutputStream();
23 BufferedWriter bw = new BufferedWriter(
24 new OutputStreamWriter(s1out));
25
26 // Send your string!
27 bw.write(“Hello Net World!\n”);










