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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:50:33+00:00 2026-05-26T07:50:33+00:00

My client is writen in java. The server is written in C. When the

  • 0

My client is writen in java. The server is written in C.
When the client read from the server, the read function return -1.
I kown in java if the outputstream closed before the socket closed, java client will receive -1. but when in C, when the java client will receive -1?

JAVA CASE:
OutputStream out = socket.getOutputStream();
out.write(buf);
out.close();
out.write(otherbuf);

In this case the when the client call read() it will return -1.

If server is writen in c, when the java client will return -1??
Thanks.

  • 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-26T07:50:33+00:00Added an answer on May 26, 2026 at 7:50 am

    What language the server is written in is irrelevant. It could be written in anything, the client does not know and should not care (in general).

    A read will return -1 when it reaches the end of stream, as documented. The end of stream happens when the other side closed that side of the (TCP) socket.

    (On the C side, assuming a POSIX system, the socket can be closed either with the close(2) system call, or with the shutdown(2) system call. The later allows the program to only close one “side” of the connection, i.e. close the write side but keep the read side open. close shuts both sides down.)

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

Sidebar

Related Questions

I have a client-server application written in Java using CORBA for the communication. The
I am working on a simple client-server project. Client is written in Java, it
I'm working on a server written in Java, and a client (a desktop application
I have written a java client server application (not http), which i need to
I have a very simple client server code written java(server listens on some port
I am reviewing a client-server application written in Java. The server receives JMS messages
Hey all. I have a server written in java using the ServerSocket and Socket
I have a server - client pair written in java and I would like
I'm trying to write a client-server application in Java with an XML-based protocol. But
I am new to java NIO. I have to write a simple server client

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.