Thu Dec 03, 2009 11:24 am
Fri Dec 04, 2009 12:31 pm
Fri Dec 04, 2009 9:06 pm
Sun Dec 06, 2009 4:54 pm
import java.net.*;
import java.io.*;
public class Client {
public static void main(String args[]) throws IOException {
Socket clientSocket = new Socket("localhost",1234); // Open your connection to a server, at port 1234
DataInputStream dis = new DataInputStream(clientSocket.getInputStream()); // for receiveng from server
DataOutputStream dos = new DataOutputStream( clientSocket.getOutoupStream()); // for sending to server
String st = new String (dis.readUTF());
System.out.println(st);
// When done, just close the connection and exit
dis.close();
s1In.close();
s1.close();
}
}
import java.net.*;
import java.io.*;
public class Server {
public static void main(String args[]) throws IOException {
ServerSocket serverSocket = new ServerSocket(1234); // Register service on port 1234
Socket connectionSocket =serverSocket.accept(); // Wait and accept a connection
// Get a communication stream associated with the socket
DataInputStream dis = new DataInputStream(connectionSocket.getInputStream()); /for receiving from client
DataOutputStream dos = new DataOutputStream( connectionSocket.getOutoupStream()); // for sending to client
// Send a string!
dos.writeUTF("Hi there");
// Close the connection, but not the server socket
dos.close();
s1out.close();
s1.close();
}
}
Mon Dec 07, 2009 12:57 am
Mon Dec 21, 2009 12:02 am
public void Connect(){
String Adress = getAdressServer().getText();
try {
clientSocket = new Socket(Adress,1234);
DOS = new DataOutputStream(clientSocket.getOutputStream());
DIS = new DataInputStream(clientSocket.getInputStream());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
System.out.println("Neispravna adresa servera");
} catch (IOException e) {
System.out.println("Neispravan unos");
}
}
private JButton getSende() {
if (POSALJI == null) {
Send = new JButton();
Send.setBounds(new Rectangle(351, 197, 136, 28));
Send.setText("SEND");
Send.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
DOS.WriteUTF(getSentence.getText());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}
return Send;
}
Mon Jul 05, 2010 8:19 pm
Thu Jul 22, 2010 1:13 pm
Fri Sep 24, 2010 4:39 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.