Forums Register Login

Head First Java-15 th chapter

+Pie Number of slices to send: Send
Hi All,

Just now atarted reading "Make a Connetion"(chapter 15) from head first java.Until this time,i am executing all my java progams in netbeans.Can i execute client and server code here itself.What they mean by socket and what is port?I thought Socket class is used to make a connection to the server.please,Give more details about it.
+Pie Number of slices to send: Send
Before starting into the fun and interesting world of network programing, you need to learn the basics.

HF Java should cover the basics of what a port is, ect.

Basically:

A socket is an abstraction. You can not literally connect to a computer on the internet. It is not very practical to hardwire your machine to one 1000 miles away.

A socket approximates this, by initially sending basic information about you to a server(IP address, port, ect), and the server keeps this data during the connection(at least for TCP sessions),

A port is analogous to an operating system process ID. there is nothing magical about them, it is just a number(short) that the OS assigns to network programs. This way, the OS knows which program to forward the incoming data to. Without them, only one program could connect to the internet/network.
Ports from 0 to 1023 are called well-known ports and should only be used to implement established protocols(ie HTTP, FTP, echo, ect). The are controlled by the Intrernet Assigned Numbers Authority. Ports from 1024-49000ish(I forget the exact number) are registered ports, they are not controlled by the IANA, but different port ranges are described for different uses. The rest are uncontrolled and basically free-for-alls.

A socket normally connects to a server, but servers also use them to communicate back to clients. They are also used in peer-to-peer.

"Can i execute client and server code here itself"

Not sure what you mean.

IMO, you should learn about basic underpinnings of network protocols first. How and what TCP/IP and UDP/IP do. What IP addresses are and how they are resolved, submasks, ect. Also, little-endian vs big-endian and how to over come byte-order differences; and reading and writing bytes are especially important if your server or client will communicate with lots of different OS's and are not necessarily written in Java. I suppose you don't really need to know this stuff to use Java implementations, but knowing it helps you use the java.net API more effectively and you will know when and why are you going in the wrong direction.

So read up on basic networking, and then dive into Socket programming. If you want other references other then HF Java, try the tutorials at Sun's website. A reasonably decent beginers book is "TCP/IP Sockets in Java" by Calvert/Donahoo. It is less then $20 also.
+Pie Number of slices to send: Send
Robert thankyou very much for your kind information.Ya...first i will go learn the basics of network programming.
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1089 times.
Similar Threads
How to create a chat server for my hostel
Question about ServerSocket port number and Socket port number
What extra can be done to do well on threads
Head First Java Chapter 15 Questiion
Java networking, nothing happens
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:26:37.