ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3114Developing Tcpip Clien…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3114

    Advanced Computer Programming

    Progress0 / 12 done
    Topics12
    1Abstract classes and Interfaces2Packages and Exception handling3Advanced issues of GUI and event handling4Applets and Swing
    5JDBC6Multithreading7Building Client/Server and implementing protocols8RMI (Remote Method Invocation)9Java Secure Socket Extension and Secure Sockets Layer (SSL)10SSL Socket and SSL Server Socket classes
    11HTTPS12Developing TCP/IP client and server with telnet
    4 min read
    Topic 12 of 12
    Topic Study Note Illustration
    12

    Developing TCP/IP client and server with telnet

    A TCP/IP client-server system is a network communication model where:

    🌐 Developing TCP/IP Client and Server with Telnet (Java Networking)


    πŸ”· 1. Definition

    πŸ”Ή TCP/IP Client-Server Model

    A TCP/IP client-server system is a network communication model where:

    • Client sends request
    • Server listens and responds
    • Communication happens using TCP

    πŸ‘‰ TCP ensures:

    • Reliable communication
    • Ordered data delivery
    • Error checking

    πŸ”Ή Telnet

    Telnet is a network protocol and tool used to:

    • Connect to remote servers
    • Test TCP connections manually
    • Send simple text-based commands

    πŸ‘‰ It works on port 23 (default)


    πŸ”· 2. Purpose of TCP/IP Client-Server

    • Build network applications
    • Enable communication between systems
    • Exchange data over internet or LAN
    • Used in chat apps, file transfer, remote services

    πŸ”· 3. TCP Client-Server Architecture

    πŸ“Š Diagram Description:

    Client β†’ TCP Socket β†’ Network β†’ Server Socket β†’ Server Process Response flows back similarly


    πŸ”· 4. Key Classes in Java

    Class Purpose
    Socket Client-side connection
    ServerSocket Server-side listening
    InputStream Receive data
    OutputStream Send data

    πŸ”· 5. Steps to Create TCP Server

    βœ” Step-by-step:

    1. Create ServerSocket
    2. Wait for client connection (accept())
    3. Read data from client
    4. Send response
    5. Close connection

    πŸ”Ή TCP Server Example

    import java.net.*;
    import java.io.*;
    
    public class TCPServer {
        public static void main(String[] args) throws Exception {
    
            ServerSocket serverSocket = new ServerSocket(5000);
            System.out.println("Server started... Waiting for client");
    
            Socket socket = serverSocket.accept();
    
            BufferedReader in = new BufferedReader(
                new InputStreamReader(socket.getInputStream()));
    
            String msg = in.readLine();
            System.out.println("Client says: " + msg);
    
            serverSocket.close();
        }
    }
    

    πŸ”· 6. Steps to Create TCP Client

    βœ” Step-by-step:

    1. Create Socket
    2. Connect to server
    3. Send message
    4. Close connection

    πŸ”Ή TCP Client Example

    import java.net.*;
    import java.io.*;
    
    public class TCPClient {
        public static void main(String[] args) throws Exception {
    
            Socket socket = new Socket("localhost", 5000);
    
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            out.println("Hello Server");
    
            socket.close();
        }
    }
    

    πŸ”· 7. Using Telnet for TCP Testing


    πŸ”Ή What Telnet Does

    Telnet can act as a simple TCP client to:

    • Connect to server
    • Send raw text data
    • Test port connectivity

    πŸ”Ή Command Example

    telnet localhost 5000
    

    πŸ‘‰ This connects to server running on port 5000


    πŸ”Ή What Happens:

    1. Telnet opens TCP connection
    2. User types message
    3. Server receives message
    4. Server responds (if programmed)

    πŸ”· 8. TCP Communication Flow

    πŸ“Š Flow:

    1. Server starts (listening)
    2. Client connects (Socket)
    3. Data exchange happens
    4. Connection closed

    πŸ”· 9. Features of TCP

    • Reliable communication
    • Connection-oriented
    • Error checking
    • Data delivered in order

    πŸ”· 10. TCP vs UDP (Important)

    Feature TCP UDP
    Reliability High Low
    Speed Slower Faster
    Connection Yes No
    Example Web, Telnet Streaming

    πŸ”· 11. Advantages of TCP Client-Server

    • Reliable communication
    • Easy to implement in Java
    • Supports multiple clients
    • Widely used in real systems

    πŸ”· 12. Disadvantages

    • Slower due to overhead
    • Requires connection setup
    • Not suitable for real-time systems

    πŸ”· 13. Important Rules

    • Server must run before client
    • Ports must match
    • Always close sockets
    • Handle exceptions properly
    • Use correct port numbers (>1024 recommended)

    πŸ”· 14. Diagram Description (Exam Tip)

    πŸ“Š TCP Client-Server Model:

    Client (Socket) β†’ Request β†’ ServerSocket β†’ Server processes request ← Response ← Client

    Telnet can replace client in testing phase


    πŸ“ Likely Exam Questions

    1. What is TCP/IP client-server model?
    2. Explain TCP server program in Java.
    3. Write a TCP client program.
    4. What is the role of ServerSocket?
    5. What is Telnet used for?
    6. Explain TCP communication flow.
    7. Difference between TCP and UDP.
    8. How does Telnet work with TCP?
    9. Advantages of TCP programming.
    10. Explain socket programming in Java.

    πŸ“Œ Quick Revision Summary

    • TCP = reliable connection-based protocol
    • Client uses Socket
    • Server uses ServerSocket
    • Data is exchanged using streams
    • Telnet = tool to test TCP connections
    • Communication is bidirectional and reliable

    ← Previous topic 11
    Client and Server Authentication: HTTPS

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    4mremaining
    595words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Advanced Computer Programming