소켓 버퍼 클리어?

syrinx40의 이미지

안녕하세요
리눅스 2.6.32를 기반으로 WiFi로 소켓통신 프로그램 작성중에 있습니다.

특정 시점에서 Rx를 하면 그전에 Rx 했었던 내용이 먼저 읽혀집니다...

실제 데이터를 Rx 하기전에 기존에 있는 소켓 버퍼를 클리어 하고 싶은데

어떤 방법이 있을가요?

// 기존에 버퍼를 지우고 싶음...
read(g_rx_socket, g_rx_psdu, A_MAX_PHY_PACKET_SIZE);

rgbi3307의 이미지

아래 함수 사용이 해답이 될수 있을듯...
sync()
fsync()
fdatasync()
fflush()

From:
*알지비 (메일: rgbi3307(at)nate.com)
*커널연구회(http://www.kernel.bz/) 내용물들을 만들고 있음.
*((공부해서 남을 주려면 남보다 더많이 연구해야함.))

syrinx40의 이미지

위에 명령어들은 buffer를 flush 하는것은 맞는데
buffer 내용을 disk에 쓴다고 하네요...

제가 원하는것은 그냥 flush만 하면될것같고
참고로 V210 개발보드에서 작업하여 disk는 따로 존재하지 않습니다.
혹시나 해서 fflush()를 한번 사용해보니
에러가 발생하네요...

SEGV

rgbi3307의 이미지


ret = read(fd, buf, len)에서 반환하는 값인 ret은 다음과 같이 4가지 경우가 있을 수 있습니다.

(1) ret == len 인 경우: len 크기의 모든 바이트를 읽어서 buf에 저장함.
(2) 0 < ret < len 인 경우: 읽는 도중에 중단된 경우 혹은 len 크기를 모두 읽기전에 EOF에 도달한 경우.
(3) ret == 0 인 경우: EOF 이거나 읽을 데이터가 없는 경우.
(4) ret == -1 인 경우: 오류 발생.

참고로, 아래는 read()를 좀더 완벽하게 하는 코드 입니다.

ssize_t ret;
 
while (len != 0 && (ret = read (fd, buf, len)) != 0) {
	if (ret == -1) {
		if (errno == EINTR) continue;
		perror ("read(): error");
		break;
	}
	len -= ret;
	buf += ret;
}

From:
*알지비 (메일: rgbi3307(at)nate.com)
*커널연구회(http://www.kernel.bz/) 내용물들을 만들고 있음.
*((공부해서 남을 주려면 남보다 더많이 연구해야함.))

stypr의 이미지

특정 시점에 Rx 을 했다고 하셨는데, 무슨 말씀이신지? WIFI 의 rx interrupt 을 enable 하셨다는 말씀이세요 아니면 read(2) 을 호출하였다는 말씀이신지..?

cinsk의 이미지

rx -> read라고 가정하고, socket이든 아니든, input buffer를 flush?하는 것은 불가능합니다. 좀 더 정확히 말하면, flush란 말은 output buffer에만 적용될 수 있는 용어입니다.

input buffer를 지우고 싶다면 읽어서 지우는 방법밖에 없습니다.

댓글 달기

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