[완료]윈도우와 유닉스 간에 소켓 통신 질문

anaud2의 이미지

안녕하세요

유닉스와 윈도우간 소켓 통신을 구현하고 있는 초급자입니다.
현재 유닉스(서버) 윈도우(클라이언) 인디언 문제가 생각이 되어
데이터를 주고 받을때 char[]로 주고 받습니다.

일반 에코서버를 구현했을때 메세지전송을 함수로 만들었습니다. 먼저 제가 보낼 바이트수를 char[]로 변환해서 전송하고 받는측은 그걸 int로 변환한후
사전에 보낸 바이트수가 들어올때 까지 대기하는거죠(내용은 표1)

그런데 일반적인 문자를 입력받아서 서버에 전송 받는건 아무런 문제가 없었습니다.
문제는 openssl의 aes를 사용해서 메세지를 암호화해서 전송을 했을때 문제가 되는거죠

암호화해서 전송을 하면 복호화가 안되는거 같습니다.
에러는
evp_enc.c(282): OpenSSL internal error, assertion failed: int > 0 Aborted
라고 나오네요

무슨에러일까요...전송이 잘못되고 있는것인가... 휴 도움부탁드립니다.

===============================
표1
===============================
int
send_to(int clnt_sock, int parityInt, char *totalbuf)
{
int str_len =0;
int str_len2 = 0;
char parityChar[4];

memset(parityChar,0x00,sizeof(parityChar));
sprintf(parityChar,"%d",parityInt);

while(sizeof(parityChar) > str_len2)
{
str_len = send(clnt_sock, parityChar, sizeof(parityChar)-str_len2, 0);
str_len2 += str_len;
}
str_len2 =0;
str_len =0;

while(parityInt> str_len2)
{
str_len = send(clnt_sock, totalbuf, parityInt- str_len2, 0);
str_len2 += str_len;
}
return 0;
}
//extern "C" _declspec(dllexport)
int
recv_from(int clnt_sock, int *parityInt, char *totalbuf)
{
int str_len=0;
int str_len2=0;
char parityChar[4];

*parityInt =0;
memset(parityChar,0x00,sizeof(parityChar));

while(sizeof(parityChar) > str_len2)
{
str_len = recv(clnt_sock, parityChar, sizeof(parityChar) - str_len2, 0);
if(str_len == 0) return 1;
str_len2 += str_len;
}
*parityInt = atoi(parityChar);
str_len2 =0;
str_len =0;

while(*parityInt > str_len2)
{
str_len = recv(clnt_sock,totalbuf, *parityInt - str_len2, 0);
if(str_len == 0) return 1;
str_len2 += str_len;
}
return 0;

}

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.