![]() |
Helloやアメリカ合衆国へようこそ! UNIXおよびLinuxフォーラム!訪問し、当社のグローバルコミュニティに参加いただきありがとうございます。
|
|
Googleのunix.com
|
|||||||
| IPネットワーク TCP / IPを、インターネットプロトコル、ルーティング、ルータ、 UNIXおよびLinuxでは、このフォーラムのネットワークプロトコルをご覧ください。 |
その他のUNIXおよびLinuxフォーラムトピックは参考にすること
|
||||
| スレッド | スレッドスターター | フォーラム | 返信 | 最後の投稿 |
| メモリリークの問題 | kshk123 | HP - UX | 2 | 2009年5月25日 07:01午前 |
| メモリリークの問題 | sonali | 高レベルのプログラミング | 5 | 2009年5月25日 06:55午前 |
| pthreadのメモリリーク | mindTeaser | UNIXの詳細&エキスパートのためのユーザー | 4 | 2009年5月18日 01:30午前 |
| フォークのメモリリーク( ) | whererush | 高レベルのプログラミング | 7 | 2006年5月11日 11:51午前 |
| 仮想メモリとメモリのリーク | shriashishpatil | 高レベルのプログラミング | 4 | 2006年2月20日 11:31午前 |
|
|
LinkBack | スレッドツール | このスレッドを検索 | スレッドを評価 | 表示モード |
|
||||
|
メモリリーク?
こんにちはすべて、
私のクライアントサーバーアプリケーションの2つのモードで作業することができます: 1 ) 1つの方向性-クライアントがサーバにのみ送信msgs クライアントに2 ) 2つの方向-サーバー'を与える回答を' 。 [ OK ]を見えますが、最初のモードでプログラムを実行すると、短い間ですが、クライアントのアプリケーションを終了した後の操作よりもクライアントにサーバーに答えます。私は、問題を発見しようとしているが、一部taugh時間がある。 これはクライアント側のデータを読み込む機能です(私は)問題がある: コード:
int TCPClient::readSocketData(int s,
char *decodeUnifiedMsgForServer,
int n,
bool& isMsg
)
{
int bcount; int br;
bcount = 0;
br = 0;
while (bcount < n)
{
if ((br = recv(s,decodeUnifiedMsgForServer,n-bcount,0)) > 0)
{
isMsg = true;
bcount += br; decodeUnifiedMsgForServer+= br;
}
else if (br < 0) /* signal an error to the caller */
{
return(-1);
}
else {
return bcount;
}
//Y 17_04_05 -
Sleep(0);
//Y.
}
return(bcount);
}
コード:
void BrainControlComData::decodeMsg(char* decodeUnifiedMsgForServer)
{
if(strlen(decodeUnifiedMsgForServer) == 0)
{
char* error = "probably an error (see Q1 below)";
}
char* msg = decodeUnifiedMsgForServer;
int size = 4;
int lenCursorData;
int lenManipData;
int lenVzData;
//places 1 - 12 in msg are reserved for total size/ isEventMsg/ MsgID
int Web_lenOfClass;
// decode len of msg
memcpy(&Web_lenOfClass, msg, size);
int lenOfClass = ntohl(Web_lenOfClass);
int Web_MsgID;
// decode msg ID
memcpy(&Web_MsgID, msg + MSG_ID_LOCATION, size);
int msgID = ntohl(Web_MsgID);
//Y 6_07_05 -
int counter = 12;
int len = 0;
len = comData[CURSOR_DATA]->decodeMsg(msg + counter);
counter += len;
len = comData[STATE_DATA]->decodeMsg(msg);
}
私の質問は以下のとおりである: 1 )なぜ、バッファ( decodeUnifiedMsgForServer )の長さは常に0ではないとのメッセージの長さをサーバーから受信したに等しいか?私は、データがサーバーからは、正しくはあるが、ときには0の長さをチェックequasエラーログに記録されます受信されると知っている( '最初の2番目の関数の中で) -すべてのアイディアですか? 2 )私はdecodeMsgアプリケーション' '動作OKとクライアントの操作を呼び出し、行を終了しなかったと述べた。私は、このエラーは、メモリリークとは何かをしていると思う。かもしれないが、私もこの1つを理解することが最初の質問を理解した。 あまりにも多くのご協力いただきまして有難うございます。 Lenna |