네트웍 프로그래밍에서, 이게 가능한지 궁금합니다.

bsakiag의 이미지

두개의 프로세스가 있습니다. (둘중하나는 드레드입니다.)
1번 프로세스에서는 message Queue를 msgrcv()해서 TCP/IP로 send를 합니다.
2번 프로세스(스레드)에서는 상대로 부터오는 message와 1번 프로세스가 보낸 msg의 ACK 메시지를 수신합니다.

문제는, 1번에서 보낸 메시지의 ACK가 와야 다음메시지를 전송해야 하는 구조입니다.
그런데, 보내는 프로세스와 받는 프로세스(또는 스레드)가 다르다 보니.. 좀 복잡해 지는거 같아서요..

간단하게 해결 할 수 있는 방법은 없을까요?

1번에서 send하고 바로 recv()를 할 수 있으면 좋은데, 그렇게 되면 2번에서 recv() 하고 있는 것과 동시에 2개의 recv() 하는 꼴이 되어서 어디로 ACK가 올지 모르는 상황이 되버릴거 같아서, 해결책은 아닌거 같습니다.

현재는 1번에서 send하고 pthread 조건 변수를 wait_timed()를 합니다. 2번에서 ACK가 오면 signal_condition을 하고요..

더 심플한 구조가 있을거 같은데.. 조언 바랍니다.

madman93의 이미지

---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------

---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------

cinsk의 이미지

application을 message queue에서 message를 받는 thread#A와, TCP로 send/receive하는 thread#B로 나눠서 작업하면 될 것 같군요.

thread#A는 message를 받아서 내부 list? 등으로 보관하고 있고, thread#B에서 이를 하나씩 꺼내어(동기화한 후) 작업하면 될 것 같네요.

--
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/

drinkme의 이미지

왜 process(or thread)를 나누어놨는지 모르겠군요.
그냥, 보내고 받고를
하나에서 처리하시는게 flow control 하시는 데에 편하지 않나요?

저렇게 하시면 2번 process가 1번 process한테 또 알려줘야 하고,
어짜피 1번 process에는 수신부(?)가 있어야 합니다.

bsakiag의 이미지

많은 도움 되었습니다.

madman93 님// 감사합니다. 용기를 얻었습니다. ^_^

cinsk님 // 모양새(?)는 cinsk님이 언급하신 방법이 더 나아보입니다. 다음엔 꼭 참고하겠습니다.

drinkme님// 사족을 달자면, 하나로 처리할 경우, 상대편에서 Ack가 정상적으로 제때 제때 안오게 되면..
message Q에 계속 적체가 되고.. 여기까진 좋은데, Q full 이 발생되기 때문입니다.

message Q의 id와 socket fd의 멀티플렉싱만 된다면.. (select or poll)
정말 속이 후련할거 같은데.. 그게 안된다네요..

cinsk의 이미지

SysV msg*()를 쓰지 말고 local domain socket을 써서 message queue를 만드세요. 그러면 select/poll을 쓸 수 있습니다.

--
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/

댓글 달기

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