Click here to Skip to main content
16,016,962 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows Device Manager Pin
Alexander M.,11-Aug-05 1:06
Alexander M.,11-Aug-05 1:06 
GeneralRe: Windows Device Manager Pin
nripun11-Aug-05 3:11
nripun11-Aug-05 3:11 
GeneralEdit Control highlight Pin
zhaopi10-Aug-05 22:30
zhaopi10-Aug-05 22:30 
GeneralRe: Edit Control highlight Pin
Phil J Pearson10-Aug-05 23:24
Phil J Pearson10-Aug-05 23:24 
GeneralRe: Edit Control highlight Pin
Eytukan10-Aug-05 23:29
Eytukan10-Aug-05 23:29 
GeneralRe: Edit Control highlight Pin
zhaopi11-Aug-05 17:02
zhaopi11-Aug-05 17:02 
GeneralSocket Pin
sunit510-Aug-05 22:19
sunit510-Aug-05 22:19 
GeneralRe: Socket Pin
vikas amin10-Aug-05 23:28
vikas amin10-Aug-05 23:28 
There are many way's in VC++ to deal with communication with socket
1.Try the ActiveX WinSock { if u have demo project , i did not get one}
2.Use the CSocket Class {easy to use }
3.Use CAsyncSocket which is the base class for CSocket
4.Driectly use the " SOCKET " provided in windows.
Sockets are very difficult to handle in Multiple Client and Server System
try to use WinSock
I have pasted a small raw code so dont copy past it use the funda from
this code .Actually we create two socket we Bind the first on and set it
on listining mode .When a client arrives we use another socket to communicte
through that client .Remember first one is yet in listening mode. Use the
Multithreading concept if u are using MFC .


//->--------------
#define SERVER_SOCKET_ERROR 1
#define SOCKET_OK 0
{
CSocket s,a;

s.Create();

SOCKADDR_IN sin;
sin.sin_family = PF_INET;
sin.sin_port = htons(6000);
sin.sin_addr.s_addr = INADDR_ANY;

//bind the socket

s.Bind ( (LPSOCKADDR)&sin, sizeof(sin));
if(rVal == SOCKET_ERROR)
{
socketError("Failed bind()");
WSACleanup();
return SERVER_SOCKET_ERROR;
}

//get socket to listen
s.Listen (1);
if(rVal == SOCKET_ERROR)
{
socketError("Failed listen()");
WSACleanup();
return SERVER_SOCKET_ERROR;
}
s.Listen (1);
s.Accept (a,NULL,NULL);
s.Send ("hi",3);

if(s.Connect("10.0.0.17",6123))
{
int i=0;
while(i++<10)
{s.Send(m_text,m_text.GetLength());

m_text = "";
char buff[17];

int i;

while(m_text.Find('\n') == -1)
{
i=s.Receive(buff,16);
buff[i]=0;
m_text += buff;
}

AfxMessageBox(buff);
}
// m_text.Trim();

//UpdateData(false);
}
s.Close();
}

//->----------------------------


Hope this solve your need

Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
GeneralRe: Socket Pin
William.Wang11-Aug-05 0:38
William.Wang11-Aug-05 0:38 
GeneralRe: Socket Pin
Trollslayer11-Aug-05 1:16
mentorTrollslayer11-Aug-05 1:16 
GeneralRe: Socket Pin
sunit511-Aug-05 1:46
sunit511-Aug-05 1:46 
GeneralRe: Socket Pin
ThatsAlok11-Aug-05 3:59
ThatsAlok11-Aug-05 3:59 
GeneralEncoding Pin
Ali Tavakol10-Aug-05 22:13
Ali Tavakol10-Aug-05 22:13 
Generaloutlook account Pin
gecool10-Aug-05 21:16
gecool10-Aug-05 21:16 
GeneralRe: outlook account Pin
Jose Lamas Rios10-Aug-05 21:32
Jose Lamas Rios10-Aug-05 21:32 
GeneralRe: outlook account Pin
ThatsAlok10-Aug-05 22:04
ThatsAlok10-Aug-05 22:04 
GeneralRe: outlook account Pin
gecool10-Aug-05 22:55
gecool10-Aug-05 22:55 
GeneralRe: outlook account Pin
ThatsAlok11-Aug-05 1:43
ThatsAlok11-Aug-05 1:43 
GeneralRe: outlook account Pin
gecool11-Aug-05 2:37
gecool11-Aug-05 2:37 
GeneralRe: outlook account Pin
ThatsAlok11-Aug-05 3:56
ThatsAlok11-Aug-05 3:56 
GeneralSocket Client issue Pin
itkid10-Aug-05 21:12
itkid10-Aug-05 21:12 
GeneralRe: Socket Client issue Pin
Jose Lamas Rios10-Aug-05 21:27
Jose Lamas Rios10-Aug-05 21:27 
GeneralRe: Socket Client issue Pin
User 58385210-Aug-05 21:29
User 58385210-Aug-05 21:29 
GeneralRe: Socket Client issue Pin
Jose Lamas Rios10-Aug-05 21:35
Jose Lamas Rios10-Aug-05 21:35 
Generaltoolbar_icon Pin
htv2210-Aug-05 20:31
htv2210-Aug-05 20:31 

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.