[질문]소켓통신에서 응답을 못받거든요.

river0kr의 이미지

소켓통신중인데,
한쪽은 데이타를 send했는데 다른한쪽은 받는 이벤트가 발생이 안된것 같애요.
함수A는 클라이언트에서 데이타를 받아 서버에넘겨주고,
서버에서 다시받아 클라이언트에 응답해주는 건데요.

서버에서 다시 받아올때
아래부분의(===>요기로 가보세요)으로 안들어오는데 왜안들어오는지
궁금해요. 답변 기다릴께요.

int funcA(int clifd)
{

        ....

	for (;;) {

	    pfd[0].fd = clifd;
	    pfd[1].fd = Servfd;
	    pfd[0].events = pfd[1].events = 
		( POLLIN | /*POLLRDNORM | POLLRDBAND |*/ POLLPRI );


	    if ( ( n= poll(pfd, NUMSOCKS,  TIMEOUT*1000000 )) <= 0)
	    {
			if ( errno = EINTR ) continue;
			if ( n== 0 )
			{
				close(Servfd);
				if ( RequestFlag==REQUEST_YES)
					SendRejectMSG(clifd,NICE_TIMEOUT);
				return -1;
			}
			printf("select error=%d\n",errno);

	    }

	    if (
		( pfd[1].revents & POLLERR ) ||
		( pfd[1].revents & POLLHUP ) ||
		/*( pfd[1].revents & POLLPRI ) || river막음*/
		(  pfd[1].revents & POLLNVAL )
		) 
		{
			log_output("polling ret error=%d\n",n);
			close(Servfd);
			return -1;
		};
	    /* if receive from menu ... */
	    if (
		( pfd[0].revents & POLLIN ) ||
		/*( pfd[0].revents & POLLRDBAND ) ||*/
		( pfd[0].revents & POLLPRI ) /*||
		(  pfd[0].revents & POLLRDNORM )*/
		) 
		{

			memset ( snd_buffer , 0x00 , sizeof snd_buffer);
			printf("[1]\n");
		
			if (( bytesu = RecvMSG(clifd,snd_buffer)) <= 0 )
			{		
				log_output("Recv Close\n");	
				close(Servfd);
				return -1;
			}
			else if ( bytesu == 9999 )
			{
				log_output("InValid Length\n");	
				close(Servfd);
				return -1;
			}
			else if ( IsValidData(snd_buffer) != 0 )
			{
				SendRejectMSG(clifd,INVALID_FMT);
				log_output("InValid Format(%d)%s\n",bytesu,snd_buffer);	
				close(Servfd);
				return -1;
			}
			printf("[2]\n");

			time(&start);
			log_output("Request=%s\n",snd_buffer);
			if (( bytesu = SendMSG(Servfd,snd_buffer,bytesu)) < 0 )
			{		
		    	close(Servfd);
				SendRejectMSG(clifd,NICE_SEND_ERR);
				/* Send Reject(Remote-Comm Error) Data */
				log_output("Send Server Error(%d)=%d\n",Servfd,errno);
				return -1;
			}
			RequestFlag=REQUEST_YES;

	    } /* of if (FD_ISSET .....*/

		printf("[3]\n");

		/* if receive from sockfd ... */

	    if ( ==============> 서버에서는 send했는데 이부분으로 안들어오네요.
		( pfd[1].revents & POLLIN ) ||
		/*( pfd[1].revents & POLLRDBAND ) ||*/
		( pfd[1].revents & POLLPRI ) /*||
		(  pfd[1].revents & POLLRDNORM )*/
		) 
		{

			memset ( snd_buffer , 0x00 , sizeof(snd_buffer));
			printf("[4]\n");

			if (( bytesu = RecvMSG(Servfd , snd_buffer ) ) <= 0 )
			{
				printf("error from host\n");	
				SendRejectMSG(clifd,NICE_RECV_ERR);
			    	close(Servfd);
			     	return -1;
			}

			time(&finish );
			log_output("Response[elapsed=%2.1f]=%s\n",difftime(finish,start),snd_buffer);
			printf("[5]\n");

   			if (( bytesu = SendNormalMSG(clifd ,snd_buffer ,bytesu)) < 0 )
			{	printf("[6]\n");
				close(Servfd);
			     	return -1;
    		}
			RequestFlag=REQUEST_NO;
			continue;
	    } /* of if (FD_ISSET **.....*/
	} /* of for(; ; ) **/
	return 0;
}
frowt의 이미지

대충 보아하니 서버에서 받을때 블록킹으로 처리해야 하는데
잘 안된것 같군요..

근데, 이 질문은 전혀 정리도 안되고, 코딩도 이상하고, 풀소스도 아니고...
작업(혹은 공부) 하다가 소스를 대충 복사해서 올려서 질문하면
답해주러 오신 분들이 과연 친절하게 대답을 해주시겠습니까?

댓글 달기

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