커널 소켓 non-blocking으로 만들기...

MythRab의 이미지

커널코드에서 sock_create로 생성한 struct socket * 형의 소켓을 non-blocking으로 만들고 싶은데, 방법을 못 찾겠습니다.
fnctl을 커널로 내리는 것도 안되는 것 같고, 혹시 내릴수 있다해도 sock_create 명령으로는 sock->file이 생성이 되지 않아서 그 명령도 못 쓸 것 같구요...
accept에서 블럭된 상태를 풀 수 있는 방법이 없을까 고민하다가 이런 방법까지 생각을 했는데, 시그널 쪽도 생각은 했지만 그것도 안되는 것 같습니다.(내릴수 있는데 못 내리는 걸지도 모르지만 :oops: )

accept에서의 블럭 상태를 해제할 수 있는 방법중에 커널코드에 적용시킬 수 있는 방법이나, 커널 래밸 소켓을 non-blocking으로 만들 수 있는 방법이 궁금합니다.

다즐링의 이미지

정확히는 모르겠지만

tux 웹써버의 코드를 보심이 좋을뜻합니다.

------------------------------------------------------------------------------------------------
Life is in 다즐링

youngwha의 이미지

MythRab wrote:

accept에서의 블럭 상태를 해제할 수 있는 방법중에 커널코드에 적용시킬 수 있는 방법이나, 커널 래밸 소켓을 non-blocking으로 만들 수 있는 방법이 궁금합니다.

kernel level socket이라는 의미는 잘 모르겠는데,
socket을 non-blocking으로, 혹은 비슷하게 동작하도록 하고 싶으실 때,
1. select를 걸어주시는 방법.
2. fcntl을 이용해서 socket의 속성을 바꿔주시는 방법
3. fcntl이 없으시다면 socket ioctl에 non-blocking mode로 바꾸는 부분을 하나 추가해주시는 방법.
4. socket 생성 후, setsockopt를 이용해서 send/receive에
timeout을 설정하셔서 무한정 block되지 않도록 하는 방법.

정도가 생각이 납니다.
추천은 1 - 2 - 4 - 3 순이구요.

~.~

frowt의 이미지

저도 kernel socket 이 뭔지 모르겠네요..
youngwha 님이 잘 얘기를 해주셨는데 조금 더 정확하게 얘기를 해보면
select를 쓴다고 해서 blocking 이 non-blocking으로 작동하거나 하지는 않습니다.
non-blocking socket을 쓴다고 하면, select 같은 multiplexing은 필수조건입니다.
그리고 fcntl, ioctl 함수 을 사용해서 non-blocking 으로 만들어야 하는데,
OS 에 따라서 지원하는 함수가 틀립니다.
오래된 os(aix, sunos) 에서는 fcntl 을 사용하고,
최근 os는 ioctl을 사용하죠.

댓글 달기

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