Click here to Skip to main content
15,921,279 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to disable task menu item? Pin
Rickard Andersson2020-May-03 3:29
Rickard Andersson2020-May-03 3:29 
GeneralRe: How to disable task menu item? Pin
Rickard Andersson2020-May-03 3:30
Rickard Andersson2020-May-03 3:30 
GeneralRe: How to disable task menu item? Pin
no_body694-Jun-03 23:53
no_body694-Jun-03 23:53 
GeneralSOCKET & BROADCAST Pin
borini19-May-03 23:50
borini19-May-03 23:50 
GeneralRe: SOCKET & BROADCAST Pin
Rickard Andersson2020-May-03 3:23
Rickard Andersson2020-May-03 3:23 
GeneralRe: SOCKET & BROADCAST Pin
borini20-May-03 4:05
borini20-May-03 4:05 
GeneralRe: SOCKET & BROADCAST Pin
Rickard Andersson2020-May-03 5:00
Rickard Andersson2020-May-03 5:00 
GeneralRe: SOCKET & BROADCAST Pin
borini20-May-03 10:09
borini20-May-03 10:09 
i must use broadcast from project specifiation...
I use to routine to create Server socket:
As it is it runs wrong, i got an error calling listen, if i create a SOCK_STREAM instead of SOCK_DGRAM all goes well:
<br />
int passive_sock(int port, int qlen)<br />
{<br />
	struct sockaddr_in sin;<br />
	int s;<br />
	int flag=1;<br />
	int rv;<br />
<br />
	memset((char *)&sin, 0, sizeof(sin));<br />
	sin.sin_family = AF_INET;<br />
	sin.sin_addr.s_addr =INADDR_ANY;	<br />
	sin.sin_port = htons(port);<br />
	s = socket(AF_INET, SOCK_DGRAM, 0);<br />
    rv=setsockopt(s,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof(flag));<br />
	if (s<0) return -1;<br />
	if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) return -2;<br />
<br />
	if (listen(s, qlen) < 0){<br />
		return -3;<br />
		printf("listen error");<br />
	}<br />
	return s;<br />
}<br />


This is the client-side:

<br />
server.sin_family=AF_INET;<br />
server.sin_addr.s_addr=INADDR_BROADCAST;<br />
server.sin_port = htons(port);<br />
<br />
opt=(char *)malloc(10);<br />
strcpy(opt,"TRUE");<br />
//opt=(char*)TRUE;<br />
conn_socket = socket(PF_INET,SOCK_DGRAM,0); <br />
retval=setsockopt(conn_socket,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof(flag));<br />
connect(conn_socket,(struct sockaddr*)&server,sizeof(server);<br />


i've noticed that if i change from SOCK_DGRAM to SOCK_STREAM setsockopt returns -1 (error)..
The main problem is that client sends packet.. i think (sendto returns 4)
but server doesn't receive nothing.. maybe server-side is wrong..ù
What do you think 'bout it??
GeneralComboBox Control Pin
Member 34035519-May-03 23:35
Member 34035519-May-03 23:35 
GeneralCListCtrl advanced - loading Pin
JensB19-May-03 23:16
JensB19-May-03 23:16 
GeneralRe: CListCtrl advanced - loading Pin
Neville Franks20-May-03 0:28
Neville Franks20-May-03 0:28 
GeneralRe: CListCtrl advanced - loading Pin
Dominik Reichl20-May-03 0:40
Dominik Reichl20-May-03 0:40 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 2:11
JensB20-May-03 2:11 
GeneralRe: CListCtrl advanced - loading Pin
Niklas L20-May-03 2:34
Niklas L20-May-03 2:34 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 2:51
JensB20-May-03 2:51 
GeneralRe: CListCtrl advanced - loading Pin
Peter Mares20-May-03 6:01
Peter Mares20-May-03 6:01 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 6:14
JensB20-May-03 6:14 
GeneralSilly ZIP question Pin
doctorpi19-May-03 23:12
doctorpi19-May-03 23:12 
GeneralRe: Silly ZIP question Pin
JensB19-May-03 23:30
JensB19-May-03 23:30 
GeneralRe: Silly ZIP question Pin
doctorpi19-May-03 23:33
doctorpi19-May-03 23:33 
GeneralRe: Silly ZIP question Pin
Dominik Reichl20-May-03 0:50
Dominik Reichl20-May-03 0:50 
GeneralFastest Pin
Tomas Wilhelmsson19-May-03 22:39
Tomas Wilhelmsson19-May-03 22:39 
GeneralRe: Fastest Pin
jhwurmbach19-May-03 23:51
jhwurmbach19-May-03 23:51 
GeneralRegistry functions Pin
Rage19-May-03 22:18
professionalRage19-May-03 22:18 
GeneralRe: Registry functions Pin
Dominik Reichl19-May-03 22:24
Dominik Reichl19-May-03 22:24 

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.