Click here to Skip to main content
15,887,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionResource conflict on ON_UPDATE_COMMAND_UI Pin
yccheok5-Oct-10 22:52
yccheok5-Oct-10 22:52 
AnswerRe: Resource conflict on ON_UPDATE_COMMAND_UI Pin
«_Superman_»5-Oct-10 23:05
professional«_Superman_»5-Oct-10 23:05 
GeneralRe: Resource conflict on ON_UPDATE_COMMAND_UI Pin
yccheok5-Oct-10 23:13
yccheok5-Oct-10 23:13 
GeneralRe: Resource conflict on ON_UPDATE_COMMAND_UI Pin
«_Superman_»5-Oct-10 23:15
professional«_Superman_»5-Oct-10 23:15 
GeneralRe: Resource conflict on ON_UPDATE_COMMAND_UI Pin
yccheok5-Oct-10 23:36
yccheok5-Oct-10 23:36 
GeneralRe: Resource conflict on ON_UPDATE_COMMAND_UI Pin
Sauro Viti7-Oct-10 23:07
professionalSauro Viti7-Oct-10 23:07 
QuestionNeed to know how to make a custom control scroll nicely with a CView... Pin
Ben Aldhouse5-Oct-10 21:42
Ben Aldhouse5-Oct-10 21:42 
Questionsocket program is able to connect to the port which is still in TIME_WAIT [modified] Pin
Jayapal Chandran5-Oct-10 20:45
Jayapal Chandran5-Oct-10 20:45 
Hi,

1. I have written a very simple socket server.
2. It listens in post 63254.
3. First i did a socket_create, socket_bind, socket_listen so here a connection is listening.
4. Then in a loop i do the socket accpet. so here another listen.
5. the read function reads untill i input exit.
6. after that the resource id by socket_accept closes.
7. and then the main connection closes.

when i checked this process in TCPview after closing all connections i can still see the system process showing TIME_WAIT for post 63254

if i again run the socket server program it is connecting and when one full process is over all the connection is closed and the program terminated and now i can see another TIME_WAIT for the same port. but still i could connect to the same port the third time.

in stackover question answer it is said that connection cannot be done for port which is in wait state.

I opened firefox browser it opened 4 connections. when i closed it all closed and the system process showed 4 time waits for 2 minutes. all time wait stays for 2 minutes and disappears.

so what i conclude is for every connection close the time wait is occurs and cannot be avoided.

i read many posts in stack overflow flow but still wasn't sure of it.

i run the following code in command line.

My server Code

error_reporting(E_ALL);
set_time_limit(0);
ob_implicit_flush(); 

$str = '';
$buff = '';

$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if(!$s)die('Unable to create socket');

if(!socket_bind($s,'127.0.0.1',63254))
    die("\nTrying to Bind: ".socket_strerror(socket_last_error()));

if(!socket_listen($s,1))
    die(socket_strerror(socket_last_error()));

    while(1)
    {
        $acc = socket_accept($s);
        if(!$acc)die(socket_strerror(socket_last_error()));
//      echo "\n".gettype($acc);
        if(!$acc)die(socket_strerror(socket_last_error()));

        while(1)
        {
            $str = socket_read($acc,512);
            $buff.= $str;
            echo $str;
//          echo '::'.gettype($str);

            if($str===false)die(socket_strerror(socket_last_error()));
            if($str=="exit\r\n")break;          
        }

//      if(!socket_shutdown($acc,2))echo socket_strerror(socket_last_error());  
        socket_close($acc);     
        if(preg_match('/exit/',$buff))break;
    }
//echo "\nConnection closed by server\n";   
//if(!socket_shutdown($s,2))echo socket_strerror(socket_last_error());
socket_close($s);


The client code

set_time_limit(0);
$f = fsockopen('127.0.0.1',63254,$a,$b,10);
if(!$f)die('cannot connect');
echo "\nConnected: \n";
do{
    $buff = fgets(STDIN);
    fwrite($f,$buff);
}while($buff!="exit\r\n");
fclose($f);


The code is written for php but it is exactly like c so people can understand without doubts. so i posted here.

I would like to have any kind of reply related to my question.

I have also discussed about this earlier in here...

if this still exists then just have a look into it.

http://stackoverflow.com/questions/3811067/socket-program-is-able-to-connect-to-the-port-which-is-still-in-time-wait[^]

http://vikku.info/

Today's Beautiful Moments are
Tomorrow's Beautiful Memories


modified on Wednesday, October 6, 2010 2:57 AM

AnswerRe: socket program is able to connect to the port which is still in TIME_WAIT Pin
Moak5-Oct-10 23:25
Moak5-Oct-10 23:25 
GeneralRe: socket program is able to connect to the port which is still in TIME_WAIT Pin
Jayapal Chandran6-Oct-10 4:53
Jayapal Chandran6-Oct-10 4:53 
GeneralRe: socket program is able to connect to the port which is still in TIME_WAIT Pin
Moak6-Oct-10 6:39
Moak6-Oct-10 6:39 
GeneralRe: socket program is able to connect to the port which is still in TIME_WAIT Pin
Jayapal Chandran7-Oct-10 0:44
Jayapal Chandran7-Oct-10 0:44 
QuestionHooking TerminateProcess or ExitProcess Pin
NehaMishra286845-Oct-10 20:20
NehaMishra286845-Oct-10 20:20 
AnswerRe: Hooking TerminateProcess or ExitProcess Pin
«_Superman_»5-Oct-10 20:45
professional«_Superman_»5-Oct-10 20:45 
QuestionBasicExcel.Load --- crash!!! Pin
ssm19841195-Oct-10 20:11
ssm19841195-Oct-10 20:11 
AnswerRe: BasicExcel.Load --- crash!!! Pin
Richard MacCutchan5-Oct-10 21:26
mveRichard MacCutchan5-Oct-10 21:26 
AnswerRe: BasicExcel.Load --- crash!!! Pin
Sameerkumar Namdeo5-Oct-10 23:25
Sameerkumar Namdeo5-Oct-10 23:25 
Questiondate comparison Pin
ggoutam75-Oct-10 19:03
ggoutam75-Oct-10 19:03 
AnswerRe: date comparison Pin
Sameerkumar Namdeo5-Oct-10 19:17
Sameerkumar Namdeo5-Oct-10 19:17 
AnswerRe: date comparison Pin
«_Superman_»5-Oct-10 19:28
professional«_Superman_»5-Oct-10 19:28 
GeneralRe: date comparison [modified] Pin
ggoutam75-Oct-10 20:54
ggoutam75-Oct-10 20:54 
GeneralRe: date comparison Pin
David Crow6-Oct-10 3:24
David Crow6-Oct-10 3:24 
GeneralRe: date comparison Pin
ggoutam711-Oct-10 23:11
ggoutam711-Oct-10 23:11 
QuestionCDateTimeCtrl Pin
ganesh_IT5-Oct-10 19:01
ganesh_IT5-Oct-10 19:01 
AnswerRe: CDateTimeCtrl Pin
_AnsHUMAN_ 5-Oct-10 19:35
_AnsHUMAN_ 5-Oct-10 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.