Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


venkatesh
sockets
1 Answer(s)      6 years and 2 months ago
Posted in : JNDI



Advertisement
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.


Related Tutorials/Questions & Answers:
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
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
Advertisements
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
thread inside other thread - Java Server Faces Questions
is in closing the sockets I donot know exactly where can I close the second socket
What is WTLS?
), formerly known as Secure Sockets Layer (SSL
File transfer from client to server - Java Beginners
File transfer from client to server  hi,, I've been trying to make an application where the user select a file using JFileChooser and then the program directly send it to the server using client/server sockets, I've tried
Core Java Training Topics
Abstract Window Toolkit (AWT) Threads  Sockets Networking... Identifying Your Computer's IP Address Using the InetAddress Class Sockets... of a Socket Using the Remote File Copy Application Datagram Sockets
Overview of Networking through JAVA
a brief summary of networking in a very simple manner that how to use URLs, sockets... computer which is known as ?server?. 3. Sockets and Ports  In this section we are going to explain the work of sockets in more generic way
Overview of Networking through JAVA
a brief summary of networking in a very simple manner that how to use URLs, sockets... computer which is known as ?server?. 3. Sockets and Ports  In this section we are going to explain the work of sockets in more generic way
Java UDP
be used to send datagrams, using Datagram Sockets, to one another i.e. from client
Advance and Core JAVA Topics
Sockets Design Pattern JSP Servlets Java Beans Session Management For more
Adapter Pattern
take an example: Suppose there are several sockets of different sizes, and shapes in a house. Due to variation in sizes, all the sockets are not capable... different sockets. Here Adapter works as a connector. This connector connects them
UDP - User Datagram Protocol
at a time.    Experiment with UDP sockets   ... sockets  
Package categories in Java
It provides classes for network support, including URLs, TCP sockets, UDP sockets,  IP addresses, and a binary-to-text
CTutorials
++, your programming environment.    Window Sockets... Windows Sockets programming, I'm afraid the WinSock resources at StarDust have... little how-to guide on network programming using Internet sockets, or "sockets
Advanced Java Tutorials
Annotations vs. Descriptors (XML) Sockets (Java networking... through JAVA Socket and ports Server Sockets URL... Datagram Clients and Servers Non-Blocking Sockets Database and SQL
File transfer to teh server - Java Beginners
and then send it to the server using client/server sockets, I've tried many ways and non
What is iPhone SDK?
* Threads OS X Kernel * TCP/IP * Sockets * Power
Overview of Networking through JAVA
summary of networking in a very simple manner that how to use URLs, sockets... of computer networking. Sockets are just like an end-point of two-way... and operating systems. Server Sockets In common language we can
Java SE 7
for new network protocol like SCTP and Sockets Direct Protocol , addition
weblogic server
management tasks more efficient and features such as Secure Sockets Layer (SSL
Advanced Java Training
Annotations vs. Descriptors (XML) Sockets - Introduction to socket... Non-Blocking Sockets Database and SQL Fundamentals - Understand
Overview of Networking through JAVA
, sockets, and datagrams. In Java, there is a java.net package provides... that the socket is one of the most primal technologies of computer networking. Sockets...;   Server Sockets In common language we can say
Java Courses
(AWT) Threads Sockets Programming with Servlets & JSP
Best way to learn Java
Abstract Window Toolkit (AWT) Threads Sockets Programming
CORBA and RMI Books
in choosing among sockets, HTTP/CGI, remote method invocation (RMI), and CORBA..., Sockets, HTTP/CGI, and Servlets Covers in detail Netscape's ORB: VisiBroker... aspects of network programming with Java, including the use of sockets, JDBC
Java: Java Tutorials
; Sockets programming in Java: This tutorial presents an introduction to sockets programming over TCP/IP networks and shows how to write client/server...;       Java TCP Sockets and Swing Tutorial
iPhone Security and Safety Tips
protocol. The Secure Sockets Layer (SSL) encrypts all mail sent and received via
Socket and ports
Socket and ports       In common language we can say that the socket is one of the most primal technologies of computer networking. Sockets are just like an end-point
What Security Functions Do You Need for Ecommerce?
Sites SSL stands for severe sockets layer. This gives the site protection over
Socket and ports
Socket and ports       In common language we can say that the socket is one of the most primal technologies of computer networking. Sockets are just like an end-point
Java package,Java Packages
, sockets, DNS lookups, ... java.security It is used
Operating System based Web Hosting
, Secure Sockets Layer (SSL), streaming media, custom COM objects, and e
 

 

 

DMCA.com