ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am having a problem sending a byte array to a server via sockets. The Server logic (a separate thread from the client) waits for the data which apparently never comes (both client and server threads run on the same Windows PC).
The suspect client code is as follows:
Prior to running the above code the following took place:
The server was connected to port 5000 (apparently successful)
The client was connecte to “localhost”, port 5000 (apparently successful)
The client loaded a 20-byte array with 20 bytes of non-textual data.
The array is sent by the client every 5 seconds
Thanks for your time.
Last edited by l_long_island; 01-12-2012 at 12:19 PM.
Reason: added definition of byte_sender
I could be missing something here, but I don't quite see how the code you've shown us will work.
You are expecting the data to be sent out a socket, yes?
In send_Data_Via_Socket you are creating a new ByteArrayOutputStream.
Even though you are storing the reference to that new Object globally, any
association that may have been made previously, between some ByteArrayOutputStream
and a socket, does not apply to the new Object. So calling the flush method on
OutputStream should have no effect on the data in the new ByteArrayOutputStream,
In order for the data from the new ByteArrayOutputStream to be sent out a socket,
you would seemingly either have to establish a relationship between that new Object and
a socket before calling flush(), or call writeTo() and specify an OutputStream that is associated with a socket.