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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:54:20+00:00 2026-05-16T10:54:20+00:00

I have a feeling my problem is a bit strange, but here goes… I

  • 0

I have a feeling my problem is a bit strange, but here goes…

I have a C++ program (from another organization) that interacts with a camera connected to hardware via Ethernet using sockets. On the surface, the initial function that sends a message to the socket is this:

char* cmd = "#TRGON\x0d";
m_pClient->Socket_Write( (BYTE*)cmd, strlen( cmd ));

After looking digging through the code, I found the function at the lowest level that actually sends the data:

// Try to send what's in the buffer
int nFlags = 0;
int nSent = ::send( m_hSocket, (char*)m_pSendBuffer, m_nSendBufLen, nFlags );
...checking for errors, etc.

Now, the program I’m working on needs to send a similar command to the camera, except it’s written in Java. I’ve been playing with Java sockets all day and haven’t been able to get the camera to do much of anything other than connect to the appropriate address (the command there is to trigger the LED lights on).

I was looking around online and saw that this “send” command is from the Winsock library which the C++ program encapsulates. Is there any similar way to do this in Java? Or am I just not using the right combination of DataOutputStreams, sockets, etc. in Java? Is there some “import winsock” I’m missing (Googling seems to say there isn’t such a thing)?

Thanks very much for any help.

EDIT:

I don’t really know if any code will help! At this point I’m just doing basic things: connecting and trying to write to it. I’ve seemingly tried every combination, conversion, etc. This is just some test code (obviously not robust or proper, like the catch block):

InetAddress addr = null;
Socket sock = null;
ObjectInputStream in = null;
ObjectOutputStream out = null;

String msg = "#TRGON\\x0d";

try {
    addr = InetAddress.getByAddress(new byte[] { (byte) 192, (byte) 168,
        (byte) 81, (byte) 58 });

    sock = new Socket(addr, PORT);

    out = new ObjectOutputStream(sock.getOutputStream());

    out.writeBytes(msg);

    in = new ObjectInputStream(sock.getInputStream());

} catch (IOException e) {
    e.printStackTrace();
}

It’s hanging at the last line there, the in = new … as if it’s not picking up any type of input stream from the camera. I know I can continue playing around with it, but any outside advice is 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-16T10:54:20+00:00Added an answer on May 16, 2026 at 10:54 am

    Turns out the command String being sent needed a different format. Instead of

    "#TRGON\x0d"
    

    I needed to use

    "#TRGON\r"
    

    Didn’t need the hex specifier thing. Thanks for the replies!

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

Sidebar

Related Questions

I have a feeling that I already know the answer to this one, but
I have a feeling that there must be client-server synchronization patterns out there. But
I have a bit of an SQL problem. Here are my tables: areas(id, name,
I have the feeling that is easy to find samples, tutorials and simple examples
I have the feeling that Flash -based ( or Silverlight -based) websites are generally
I have a feeling this is a repost but I can't seem to find
This is a bit of a strange one, but I've been struggling for a
I am a bit lost here as I have not really looked at model
I have a feeling that this should really not be all that difficult, yet
I curious to how different people solve integration of systems. I have a feeling

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.