sockets

Ads

 
 

Share on Google+Share on Google+

venkatesh
sockets
1 Answer(s)      9 years ago
Posted in : JNDI
Ads
View Answers

July 30, 2008 at 4:45 PM


Hi friend,

import java.io.*;
import java.net.*;

public class KnockKnockClient {
public static void main(String[] args) throws IOException {

Socket soc = null;
PrintWriter out = null;
BufferedReader in = null;

try {
soc = new Socket("vinod", 135);
out = new PrintWriter(soc.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(soc.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: vinod.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: vinod.");
System.exit(1);
}

BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String fromServer;
String fromUser;

while ((fromServer = in.readLine()) != null) {
System.out.println("Server: " + fromServer);
if (fromServer.equals("Bye."))
break;

fromUser = stdIn.readLine();
if (fromUser != null) {
System.out.println("Client: " + fromUser);
out.println(fromUser);
}
}

out.close();
in.close();
stdIn.close();
soc.close();
}
}


----------------------------------------------------------------

Read for more information.

http://www.roseindia.net/java/network/interfaces-list.shtml

Thanks.

Ads









Related Tutorials/Questions & Answers:
Version of cornerstone-sockets>cornerstone-sockets-api dependency
List of Version of cornerstone-sockets>cornerstone-sockets-api dependency
Version of cornerstone-sockets>cornerstone-sockets-impl dependency
List of Version of cornerstone-sockets>cornerstone-sockets-impl dependency
Advertisements
Server Sockets
Server Sockets       In common language we can say that the sockets are just like... Sockets. The main work of ServerSocket class is to wait for a request of connection
Version of cornerstone-sockets-api>cornerstone-sockets-api dependency
List of Version of cornerstone-sockets-api>cornerstone-sockets-api dependency
Version of cornerstone-sockets-impl>cornerstone-sockets-impl dependency
List of Version of cornerstone-sockets-impl>cornerstone-sockets-impl dependency
Artifacts of cornerstone-sockets
List of Artifacts of cornerstone-sockets maven depenency
Artifacts of cornerstone-sockets-api
List of Artifacts of cornerstone-sockets-api maven depenency
Artifacts of cornerstone-sockets-impl
List of Artifacts of cornerstone-sockets-impl maven depenency
Maven Dependency cornerstone-sockets-api >> 1.0
You should include the dependency code given in this page to add Maven Dependency of cornerstone-sockets >> cornerstone-sockets-api version1.0 in your project
Maven Dependency cornerstone-sockets-api >> 2.1
You should include the dependency code given in this page to add Maven Dependency of cornerstone-sockets-api >> cornerstone-sockets-api version2.1 in your project
Maven Dependency cornerstone-sockets-impl >> 1.0
You should include the dependency code given in this page to add Maven Dependency of cornerstone-sockets >> cornerstone-sockets-impl version1.0 in your project
Maven Dependency cornerstone-sockets-impl >> 2.1
You should include the dependency code given in this page to add Maven Dependency of cornerstone-sockets-impl >> cornerstone-sockets-impl version2.1 in your project
Server Sockets
Server Sockets       In common language we can say that the sockets are just like... Sockets. The main work of ServerSocket class is to wait for a request of connection
how to connect client to server using Sockets
how to connect client to server using Sockets  how to connect client to server using Sockets
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
how to send joption panel dialog from server to multipleclients using sockets?
how to send joption panel dialog from server to multipleclients using sockets?  how to send joption panel dialog from server to multipleclients using sockets?like we get a first message with 2 buttonsand on clicking one button we
Current Running Projects on roseindia.net
communication using TCP/IP Sockets using C++ - Call Flow 1 For complete list of Projects
SSL Certificates
SSL Certificates Secure Sockets Layer or SSL for short is a protocol. It was developed by Netscape for transmitting private documents over internet. SSL uses a cryptographic system which uses two keys to encrypt and decrypt the data
Parsing The XML File Using JDOM Parser in JSP
from files, network sockets, strings, or from reader. JDOM does not has its own
VoIP Routers
sockets, to provide Voice-Over-IP (VoIP) facilities - just like having two extra
socket - Java Beginners
socket  in a chat application i have used two sockets s1 and s2... client program. i have created only one server socket for all the sockets... use multiple server sockets in a application? suppose if i will use multiple
Structural Design Patterns
there are several sockets of different sizes, and shapes in a house. Due to variation in sizes, all the sockets are not capable of plugin a mobile charger. So we use an Adapter to make it portable across different sockets. Here Adapter works
java basics
or open sockets before getting garbage collected
RMI in internet - RMI
RMI in internet  dear friends. i want to develop an application for controlling a PC from a remote location in Java. communication is done through internet. so is it possible to use RMI, or Sockets for internet communication
Java Socket
Java Socket  What is a socket?  Sockets are communication... the network. It is important to note that these sockets are software, not hardware, like a wall socket.  Sockets are communication channels, which facilitate
Ruby/EventMachine
Ruby/EventMachine       Ruby/EventMachine is a fast, simple event-processing library for Ruby programs. It lets you write network clients and servers without handling sockets- all you do
TCP socket
TCP socket  Respected sir/madam, Sir, i want to know about tcp sockets and udp datagrams which is used by mobile applications,shall i know how the chatting(sms) application can run by both people?how they enabled
TCP socket
TCP socket  Respected sir/madam, Sir, i want to know about tcp sockets and udp datagrams which is used by mobile applications,shall i know how the chatting(sms) application can run by both people?how they enabled
thread inside other thread - Java Beginners
the sockets I donot know exactly where can I close the second socket