Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: [Lesson] The socket Class  (Read 418 times)
0 Members and 1 Guest are viewing this topic.
_ikram
Member
*

Reputation: 3
Offline Offline
Posts: 65
Referrals: 0

Awards
« on: August 05, 2009, 04:24:33 PM »

[Lesson] The socket Class
Alright, the Socket class represents a socket connection on a port by means of a special object called an object, im gona show you two diffrent java classes that are designed yo work with sockets.

The Socket Class
This socket class is the class that represents a socket connection between two diffrent programs, these program dont even have to be in the same computer, thats how cool Sockets are.
Infact any two computers that are connected to the internet can communicate with each other via a socket.

Here are the most common methods and contructors used in the socket class:

Constructor
Socket()   - Creats an unconnected socket

Socket() (InetAddress adress, int port()   -Creates a socket and connects it to the specfied adress and port

Socket(String host, int port)   -Creates a socket and connects it to the specfied host and port

Method

Void Close()   -closes the socket

Void connect (InetSocketAddressendpoint)   -Connects the socket to a specifed adress.

InetAddress getInetAddress()   -Gets the adress in which the socket is connected to.


InetStream getInputStream()   -Gets an input stream that can be used to recive data sent though this socket.

OutputStream getOutputStream()   -Gets an output stream that can be used to send data via the socket.

int getPort()   - this finds the port which the socket is connected to.

boolean isBound()   -It shows if the socket is connected to the port or not

boolean isClosed()    -Shows is socket is closed.



The scocket class has certain constructors as you can see above which allows you to connect tp a spefic address.

Ikram   
Logged

RuneScape Developers community: www.rspsnetwork.com
Hextion Private Server: www.hextion.com
two0426
Junior Member
*

Reputation: 0
Offline Offline
Posts: 6
Referrals: 0

Awards
« Reply #1 on: May 31, 2010, 01:45:00 AM »

spam
« Last Edit: May 31, 2010, 02:16:31 AM by Arkie » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here