Java client => C++ 서버로의 파일 전송 문의 드립니다.

nTachyon의 이미지

안녕하세요~
java 클라이언트와 C++ 서버간의 통신을 통해 wave 파일을 보내려고 하는데
보내고 나면 10byte가 더 붙습니다.

바이너리 파일 비교를 해보면 틀린 부분도 상당히 보이고요.

C/C++만 하다가 어떻게 지시(ㅜㅡ)에 의해 java에 손대다보니 제일 막막한게 소켓이네요.
여러 종류의 stream이라는 추상화된 객체들로 수행되는 것 같은데
이게 참 C++보던 사람의 입장에서는 쉽게 다가서기가 힘드네요.
이래저래 몇 일 시도하다가 결국에는 질문 드립니다.

내용은 파일을 읽고->전송하고 의 반복 동작의 구현입니다.

통신 스펙은 간단합니다.
1. 최초 2바이트 전송
2. 파일 read -> buffer에 담기
3. 읽은 바이트수 4자리 + buffer 전송
4. 다 읽을 때 까지 2번과 3번의 반복

첨부된 압축은 푸시면

test: java Client
testServer: C++ Server (VC++ 프로젝트)
disconnected.wav: 전송할 파일(C:\ 밑에 두면 됩니다)

이렇게 3개가 있습니다.
C++ 서버쪽은 실행 하면 되겠고요
Java쪽은 eclipse에 프로젝트 넣어주시고
wave 파일은 C:\ 에 두시면
작동하는데는 문제 없을 것 같습니다.

파일 전송시에 BigEndian/LittleEndian 문제인가 싶어,
아래와 같이 해 보아도 소득을 얻지 못했습니다.
----------------------------------------------------------------------------------------------------------------------------
BufferedOutputStream bufferedOS = new BufferedOutputStream(socketOutputStream);

ByteBuffer byteBuffer = ByteBuffer.allocate(SEND_DATA_SIZE);
ByteBuffer byteBufferLittleEndian = null;

byteBuffer.wrap(bufData, 0, lenRead);
byteBuffer.flip();
byteBufferLittleEndian = byteBuffer.order(ByteOrder.LITTLE_ENDIAN);

bufferedOS.write(byteBuffer.array(), 0, byteBuffer.array().length);
----------------------------------------------------------------------------------------------------------------------------

작은 조언이 저에겐 큰 도움이 될 수 있을 것 같습니다.

좋은 하루 되세요

File attachments: 
첨부파일 크기
Package icon test.zip3.04 MB

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.