[완료] client/server모델에서 local server 에 접속했는지 판단하는 방법?

ssehoony의 이미지

client/server 모델로 프로그램을 만들었습니다.
client가 server로 접속 할 때, server를 client가 실행되는 장비와 동일한 장비에서 구동되는 경우도 있고 아닌 경우도 있을 텐데요.
client측에서 접속하려는 server가 local에 구동되어 있는지 remote에 구동되어 있는지 판단하는 방법이 있을까요?

local에 구동된건지 파악하는 간단한 방법중에 하나는 접속하려는 server의 host명을 gethostbyname()함수를 통해 ip를 얻어 온 후 ip가 127.0.0.1라면 로컬이라고 간주 할 수 있겠지만
loop back 인터페이스가 아닌 이더넷 카드 ip로 접속을 시도 할 수도 있고, 이더넷 카드가 복수개 일수도 있는 등등의 여러가지 상황이 있을텐데요.
이런 다양한 경우에도 잘 작동하는 로직이 있으면 좋겠습니다.

chadr의 이미지

클라이언트와 서버 프로그램에 각각 공유메모리를 이용해서 데이터를 주고 받을 수 있는 기능을 만듭니다.
그리고 서버에 클라이언트가 접속시 해당 클라이언트에 바인딩된 포트 번호를 얻어옵니다.

이 포트 번호를 가지고 운영체제에서 실행되는 프로세스중 이 포트 번호를 쓰는 프로세스를 얻어옵니다.
해당 프로세스에 공유메모리를 이용해서 미리 정의된 특정 이벤트를 날려서 해당 프로세스가 서버에서 원하는
프로세스인지 확인합니다. 확인해서 맞다면 해당 프로세스는 로컬에서 접속한 것입니다.

시나리오는 이렇게 생각이 되는데 될려나 모르겠습니다.
-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.

-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.

ssehoony의 이미지

client와 server 양쪽에 뭔가 장치를 해서 해결 할 수 있을 것 같습니다.

이왕이면 client의 코드만으로 알아서 해결할 수 있으면 좋겠습니다.
그렇게 하면 이런 처리를 하는 library를 별도로 만들 수 있고, 범용적으로 사용 할 수 있을테니깐요.

ssehoony의 이미지

로컬 네트워크 인터페이스의 모든 ip를 얻어 오는 방법은 뭔가요?
로컬의 모든 ip를 얻어 오기만 하면, getpeername()으로 얻어온 server의 ip와 client의 모든 ip를 비교해서 같은 것이 있다면 client와 server가 동일 장비에서 작동하고 있다고 봐도 될 것 같은데요.

댓글 달기

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