|
서버에서 다시 클라이언트로 보낸다는 얘긴가요?
ServerSocket1->Socket->Connections[i]->SendText(tmp);
물론, i 첨자는 보내려는 클라이언트가 속했있는 소켓의 index값이겠지요?
그리고, 첨언하자면..굳이 클라이언트에서 Ip정보를 서버에 보낼 필요는 없어요..
어차피 소켓의 헤더 정보에 상대받의 IP정보가 들어 있으니, IP 정보가 있으면
서버에 연결된 소켓의 remote ip 정보를 보면 알 수 있어요..
노두현 님이 쓰신 글 :
: 이건 클라이언트 전송 부분 입니다.
: 문장;IP
: 를 붙여서 서버로 보내는 건데요
: ========================
: void __fastcall TForm1::Memo2KeyDown(TObject *Sender, WORD &Key,
: TShiftState Shift)
: {
: if(Key == VK_RETURN)
: {
: temp=Memo2->Lines->Strings[Memo2->Lines->Count -1];
: ClientSocket1->Socket->SendText(temp + ";");
: ClientSocket1->Socket->SendText(ClientSocket1->Socket->LocalAddress);
: }
: }
:
: =====================
:
: 그럼 서버에서 커넥트 됏을때 커넥트 된 주소를 저장하고
:
: void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
: TCustomWinSocket *Socket)
: {
: int i;
: Memo2->Lines->Clear();
: cUser=ServerSocket1->Socket->ActiveConnections;
: Memo3->Lines->Add(cUser);
: for(i=0;i<cUser;i++)
: {
: sAddr[i]=ServerSocket1->Socket->Connections[i]->RemoteAddress;
: }
: }
: ========================
:
: 서버에서 클라이언트에서 보낸거 읽어 오는 부분입니다.
: void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
: TCustomWinSocket *Socket)
: {
: int i;
: AnsiString sss;
: tmp=Socket->ReceiveText();
: Memo1->Lines->Add(tmp);
: for(i=0;i<cUser;i++)
: {
: if(tmp==sAddr[i]){continue;}
: else ServerSocket1->Socket->Connections[i]->SendText(tmp);
: }
:
: }
:
: 이경우 IP를 기준으로 전송 하고 싶은 곳에 전송 하고 싶은데 어찌 해야 할까요...
: 일단 클라이언트에서
: 문장;IP 를 나누는게 중요한거 같은데...
|