Skip to content

About

A technical exploration and implementation of network communication protocols, focusing on architectural logic and layer-based data flow.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Android TCP Socket Client

A minimal Android app (Java) that opens a TCP socket to a server on the local network, sends a line of text, and shows the server's one-line reply in a toast. Written as the client side of a networking course milestone (project name mileston0).

Features

  • Connect button opens a java.net.Socket to a hard-coded host and port (192.168.43.226:8888).
  • Send button writes the text from the input field followed by a newline (DataOutputStream.writeBytes), then reads one line back (BufferedReader.readLine) and displays it as FROM SERVER: <reply>.

The server is not part of this repository; any TCP server that reads a line and answers with a line will work.

Known Limitations

  • Socket connect, send and receive run on the UI thread. Android blocks network calls on the main thread by default (NetworkOnMainThreadException), so they would need to move to a background thread for the app to work on current Android versions.
  • Host and port are hard-coded in client.java.

Tech Stack

  • Java, Android SDK (compileSdk/targetSdk 32, minSdk 28)
  • Android Support Library (appcompat-v7, constraint-layout)
  • java.net.Socket (TCP)

Repository Contents

app/
├── build.gradle
└── src/main/
    ├── AndroidManifest.xml                     # INTERNET + ACCESS_NETWORK_STATE permissions
    ├── java/com/example/mileston0/client.java  # the only activity
    └── res/layout/activity_main.xml            # text field, "connect" and "send" buttons

How to Run

  1. Start a line-based TCP server on a machine in the same network.
  2. Change hostName and portNumber in client.java to match it.
  3. Open the project in Android Studio and run it on a device on that network; tap connect, type a message, tap send.

Developed by Khaled Walid

About

A technical exploration and implementation of network communication protocols, focusing on architectural logic and layer-based data flow.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages