Socket Programming

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

public int getPort()

gives information on which port the Socket is connected to on the remote host

public int getLocalPort()

gives the port number for the local end of the connection

java.net.InetAddress class

a class used in most of the networking classes such as Socket, ServerSocket, URL, DatagramPacket and more

what is a socket

a socket is a connection between two hosts

IPv6

composed of eight blocks of four hexadecimal digits separated by colons

IPv4

composed of four unsigned bytes, each byte ranges from 0 to 255, also called dotted quad format

sockets seven basic functions

connect to a remote machine, send data, retrieve data, close a connection, blind a port, listen for incoming data, accept connection from remote machines on the bound port

public Socket(String host, int port)

creates a TCP socket to the specified port on the specified host and attempts to connect to the remote host

3 static methods of java.net.InetAddress

getByName(), getAllByName() and getLocalHost()

public InetAddress getInetAddress()

gives information about the remote host the Socket is connected to

what does java.net.Socket do

performs client-side TCP operations

how java programs normally use client sockets

program creates a new socket with the constructor, socket attempts to connect to the remote host, once the connection is established the local and the remote hosts can exchange data, one or both sides closes the connection after the data transmission is complete

why is a socket bound to a port number

so that the TCP layer can identify the application that data is destined to be sent to

public InetAddress getLocalAddress()

tells which network interface a socket is bound to


Kaugnay na mga set ng pag-aaral

Chapter 1 - Introduction to Privacy

View Set

Urinalysis Ch 5 Practice Questions

View Set

31 Pairs of Spinal Nerves & 12 Pairs of Cranial Nerves

View Set

Ch. 22 & 23- Common Child and Adolescent Mental Health Disorders

View Set