python socket - How to instantiate a socket - java socket tutorial - socket - socket io - python socket - java socket - socks proxy - socket programming
How to instantiate a socket class object
Instantiating a socket can be done in various ways.
- By 2 line declaration & instantiation:
- First we need to define a variable which will hold a Socket class object:
- Then we can create a Socket class object:
- We can also make a one line definition & instantiation:
- Both ways will create an unconnected socket.
- We can use other parameterized constructors to instantiate connected or unconnected socket class object:
For details see class doc specs:
https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html