C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[55365] 소스좀 봐주세요!
Terry [] 2758 읽음    2008-12-08 15:47
UDP로 간단하게 데이터 주고받는 기능을 만들고 있는데요
서버쪽에서 컴파일시에 에러는 없는데 실행되고 나서 쓰레드 스타트후에 먹통이 되네요

서버쪽 소스
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
    IdUDPServer1->DefaultPort = 9500;
    IdUDPServer1->Active = true;
    IdUDPServer1->BroadcastEnabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::IdUDPServer1UDPRead(TObject *Sender, TStream *AData,
        TIdSocketHandle *ABinding)
{
    char              str[1024];
    ZeroMemory(str, sizeof(str));

    AData->ReadBuffer(str, AData->Size);

    Memo1->Lines->Add(str);

    TByteDynArray data;
      IdUDPServer1->SendBuffer(ABinding->PeerIP,ABinding->PeerPort,Id_IPv4,data);
}

클라이언트쪽 소스
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
    IdUDPClient1->Active = true;
    IdUDPClient1->Port = 9500;
    IdUDPClient1->BroadcastEnabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
    AnsiString stReceive;

    IdUDPClient1->Send(Edit1->Text); // 서버로 데이터 전송

    stReceive = IdUDPClient1->ReceiveString(); //데이터 수신
    Memo1->Lines->Add(stReceive);
}
//---------------------------------------------------------------------------
코드기어 C++빌더 2007을 쓰고 있습니다  인디 10.대 버젼이구요

+ -

관련 글 리스트
55365 소스좀 봐주세요! Terry 2758 2008/12/08
55367     Re:소스좀 봐주세요! iwillgosu 1715 2008/12/08
55369         Re:Re:소스좀 봐주세요! Terry 1971 2008/12/08
55389             Re:Re:Re:소스좀 봐주세요! iwillgosu 1667 2008/12/09
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.