473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

storage size of 'sin' isn't known

1
hi,

i'm having the problem with my first socket program...i have been staring at it for an hour but i cant find whats wrong with it...can u check it out pls?

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/socket.h>
  4.  
  5. int main(){
  6.  
  7.  
  8.     struct hostent *phe;
  9.     struct sockaddr_in sin; //here is the problem!!!!!
  10.     char *host;
  11.     int s, rc, type;
  12.  
  13.     host = "tombaker.cis.um.edu.mt";
  14.     //memset(&sin, 0, sizeof(sin));
  15.  
  16.     sin.sin_family = AF_INET;
  17.     sin.sin_port = 7; //ECHO service
  18.     sin.sin_addr = inet_makeaddr(
  19.             inet_network("193.188.43.36"),
  20.             inet_addr("193.188.43.36"));
  21.     s= socket(PF_INET, SOCK_STREAM, 0);
  22.     rc = connect(s, (struct sockaddr *)&sin, sizof(sin));
  23.     if (rc != 0)
  24.      printf("failed");
  25.     else (printf("connected"));
  26.  
  27. }
Oct 15 '08 #1
3 6879
gpraghuram
1,275 Expert 1GB
In which OS you are doing this?
Becos the sockaddr_in is definde in different header file and you are missing that inclusion


Raghu
Oct 16 '08 #2
Hi I had a look at the program, are you using LINIX?

if so try:
#include <netinet/in.h>

I believe you would probably find a few more errors downstream though
Oct 21 '08 #3
I have been looking at the code but can't seem to get:

sin.sin_addr = inet_makeaddr(
inet_network("193.188.43.36"),
inet_addr("193.188.43.36"));

line working. Don't know what is wrong here it looks correct? How did you go after you added the include file is it working on your system?
Oct 22 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: franky.backeljauw | last post by:
Hello, I have the following code: <code> class X { ___ sin(); } X sin( X ) { return sin( y, x ); }
1
by: DiskMan | last post by:
System: Redhat 7.2 Kernel-2.6.11.8 GCC-3.4.3 CCC-6.5.9 Binutils-2.15 Make-3.80 GTK/GLIB-2.6.7 For some reason my Linux box is suddenly having issues trying to read ;
12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
1
by: Madhusuthanan Seetharam | last post by:
Hi all, I'm a newbie to C. What does the error message "storage size of 'xxxxx' isn't known mean? TIA, - Madhu
2
by: Gvs | last post by:
Hi, I'm trying to compile an example semaphore .c file taken straight from the internet, but it won't compile with the error; gcc seminit.c -o seminit seminit.c: In function `main':...
3
by: Bas Wassink | last post by:
Hello there, I'm having trouble understanding a warning produced by 'splint', a code-checker. The warning produced is: keywords.c: (in function keyw_get_string) keywords.c:60:31: Released...
5
by: walsht | last post by:
When I compile the code snipets below I'm producing the error: storage size of 'frm' isn't known. dll.h : /* * File: dll.cpp * Defines the data link layer's interface. */ #ifndef __FRAME_
3
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I get a strange compile error when compile such simple program. Any ideas? foo.c: In function `main': foo.c:5: error: storage size of 'var' isn't known foo.c
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.