Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3805534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:41:35+00:00 2026-05-19T14:41:35+00:00

Im trying to send multiple data items over a tcp socket from an android

  • 0

Im trying to send multiple data items over a tcp socket from an android client to a python server. The user on the client side can make multiple choices so im using a number sent as a character to differentiate between request types. I have to send the choice and specific data depending on the choice.For the current selection (choice no 1 in this case) I need the choice and 2 string fields and an image. I have the image transfer working on its own and the choice working on its own. The problem I am having now is that the buffer reading in the choice is also reading in the byte stream of the image straight after it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:41:36+00:00Added an answer on May 19, 2026 at 2:41 pm

    TCP will combine your writes into one packet if they are written before the packet is sent, meaning the information will be received concatenated.

    A common solution would be to incorporate an ‘opcode’ before your data.
    For example, prefix CHOICE before sending your integer. When you read CHOICE in your python script, you know you are receiving an integer and thus read just that much data.
    Before you send your image, prefix it with IMG and the number of bytes to read. This way you can read just as many bytes as needed, then look for the next opcode.

    Your packet should then look like this:CHOICE1IMG<number of bytes><image bytestream>

    Obviously your opcode can be whatever you want, this is just an example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send multiple data from server to client using TCP. I
I am trying to send data from multiple checkboxes (id[]) and create an array
i am trying to send multiple data using j query $.ajax method to my
I'm trying to send back multiple variables from a php file to ajax using
I`m trying to send simple html page with form data to user with GET,
I'm trying to insert multiple rows using SqlCommand from C# to SQL Server. I'm
I am trying to conceptually work through a model for a client-server socket application
I am trying to send data to my controller from an ajax function that
Trying to send an array from: <select name='galaddvenn[]' class='sel_add vl hidden' multiple='multiple'> <option value='53'>name1</option>
I am trying to send data to a web server using a post, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.