멀티 스레드에서 하나의 세션(connected socket)을 이용하는 전송을 시작하는 주체에 따른 문제점 발생

jms_jms의 이미지

안녕하세요?

TCP/IP에 관련된 질문을 드립니다.

일단 구현의 용이성 때문에 동기식으로 구현을 했구요...ㅠ.ㅠ

Client ========HEARTBEAT=====> Sever (Application heartbeat (주기적)) ==> 스레드 1개
<========HEARTBEAT_ACK=====
--------------------------------------------------------------------------------------------------------------
Client <======MSG============== Server (특정 메시지 (비 주기적)) ===> 스레드 1개
=========MSG_ACK======> Client (특정 메시지 ACK)
--------------------------------------------------------------------------------------------------------------

이런식의 스레드가 존재하게 되는데....이때 스레드는 동일한 소켓을 사용하게 됩니다. [동일 세션 사용]

스레드간의 Lock 처리를 통해서 손쉽게 될 줄 알았는데....

lock 처리를 한다고 하더라도.. 문제가 생기네요..ㅠ,ㅠ. 일단 다른쪽에서 수신대기를 함으로 인해서... 본래 스레드가 수신을 해야할
메시지를 처리하고 있는데...ㅠ,ㅠ. 쩝.. 해결할 수 있는 손쉬운 방법이 없을까요?

메시지 전송측을 한쪽으로 몰아 버리게 된다면... lock으로 처리로 될 수 있을 것 같아 보입니다.

아래와 같은 방법 말고 아래와 같은 방법 말고 다른 방안이 없을까요?

locking
<======heartbeat===========
=========ACK=======>
unlocking

locking
<========특정 메시지======
==========메시지 ACK ====>
unlocking

TCP/IP 소켓은 아예 잼병이라서 어렵네요..

읽어주셔서 감사합니다.

익명 사용자의 이미지

간단하게 그냥

서버와 클라이언트에 모두 비동기적으로 처리하시면 될 듯 한데..

프로토콜 하나 만드시고 프로토콜중 HEARTBEAT역할의 프로토콜을 만드신 후

세션객체의 멤버를 하나 만드시는데 이 멤버가 최종 HEARTBEAT타임입니다. 이 타임을 다른 스레드에서 주기적으로 체크하도록 하고ㅓ

일정 시간이 지나면 디스커넥트 처리하게 되는 거지용

댓글 달기

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