UDP 와 EPOLL 에 대해서 질문~

evalion의 이미지

안녕하세요.
이번에 윈도우 IOCP에서 돌리던 코드를 리눅스 EPOLL 로 포팅중인데, 생각보다 어려움없이 깔끔하게 잘 진행되고 있습니다. ^^
리눅스에서 EPOLL 로 소켓 이벤트를 처리하는데 TCP 처리는 제대로 가져오는데 UDP 이벤트는 체킹을 못하더라구요. 혹 제가 잘못 사용하는것인지 UDP 정도면 SELECT 로 처리해도 문제 없을듯 싶지만 EPOLL 로 UDP 관리도 되는것인지 궁금합니다.

그리고 UDP 로 가상 TCP를 구현하려 합니다. UDP 가 순서없이 들어오고, 보낸패킷의 크기가 변하지않고, 유실된다는것 외에, 혹시 보낸 바이트수와 같은 바이트수를 받더라도 안의 내용이 변할 수 있나요? 그러니까 체크섬을 따로 구현해야 하는지 궁금합니다. TCP 같이 정확하게 데이터를 주고받는게 목적이라 상당히 중요한 이슈거든요. 아직까지 패킷이 유실될 망정 내용이 변하는것은 보지 못했는데 그런 여지가 있는것인가요?

감사합니다~

s = CreateUDPServerSocket(m_nPort);

epoll_event ev;
ev.events = EPOLLIN;
ev.data.fd = s;
epoll_ctl(epoll, EPOLL_CTL_ADD, s, &ev); // 리스닝 소켓 이벤트 등록

while(true)
{
if(bServerStop) // 서비스 종료
break;

int n = epoll_wait(epoll, events, 1, 1000);

char msg[256];
sprintf(msg,"반환값 - %d",n);
pLog->WriteLog(msg);

if(n == 0) // 타임아웃
continue;

if(n == -1) // 무언가 오류발생
{
sleep(1);
continue;
}

// UDP 모드에서는 이벤트가 들어오면 무조건 수신한다.
int nRet = recvfrom(s, buffer, BUFFER_SIZE, 0, (sockaddr*)&sockAddr, (socklen_t*)&nLen);
if(nRet > 0)
UDPPacketRecved(nRet, &sockAddr);
}

서버는 위와같이 구현되어있고, 바인드된 포트로 외부에서 SENDTO 를 해도 이벤트가 발생하지 않고있습니다.

댓글 달기

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