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 5932817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:53:15+00:00 2026-05-22T14:53:15+00:00

I am experiencing weird behavior: I have a server, based on a java ServerSocket

  • 0

I am experiencing weird behavior:

I have a server, based on a java ServerSocket that serves TCP request that are send from iPhone device.
I have noticed that when I use the iPhone is connected via wi-fi, there are no problems with the networking. The iphone opens a connection and than write and read from the stream as it should, with no noticeable latency. So far so good.
Working with 3g, however, I am experiencing 1.5 seconds latency from the second the first message is sent until the response is fully arriving back. It seems that the first byte of the message is read right after the server flushes the message to the socket, but the rest of the message is being delayed for about a second(!).

I verified this network behaviour by both printing the buffer size that arraive on the iphone side and by monitoring the networking with wireshark on the server side.
Wireshark shows this as well – the first byte, is sent in a 1 byte message size (it is always 0 BTW), and the rest of the message is sent afterwards, in one or more large messages (~1300 bytes).

The message is composed of an 8 byte header (2 integers – type and size), and a body of that size.

The real weird thing is that writing similar server that uses the same protocol in c++ (using poco server), is working perfectly.

I use the DataOutputStream of the socket to write the header using 2 writeInt instructions and a write(byte[]) that writes the body. I then flush the stream.

Does anyone knows if there’s a socket option (in java) that can cause this kind of behaivour?

Any help will be appreciated.

  • 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-22T14:53:16+00:00Added an answer on May 22, 2026 at 2:53 pm

    I solved that issue, by wrapping the socket output stream with a BufferedOutputStream:

    DataOutputStream dos = new DataOutputStream(new BufferedOutputstream(sock.getOutputStrean()));
    

    Thanks,
    Lior

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

Sidebar

Related Questions

I am experiencing weird behavior with template toolkit, say I have a data structure
I have been experiencing a weird problem that I can't find a solution to.
I am experiencing a weird behavior by Scala handling of superclass constructors. I have
I'm experiencing this weird problem which my scrollbar jumps by itself to somewhere that
I'm experiencing a weird scrollbar issue. I'm building a page that uses jQuery and
I am experiencing something weird and have a workaround already, but I don't think
I seem to experiencing a weird error where my request params seem to be
I'm experiencing really weird behavior with the Socket.Connect method in C#. I am attempting
I'm experiencing some weird behavior with SELECT statements in sqlite. There is one table
I'm experiencing a weird issue in which I need to have a default constructor

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.