Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem z socketem
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW
View previous topic :: View next topic  
Author Message
MarcinS21
n00b
n00b


Joined: 12 Feb 2006
Posts: 26
Location: Kraków

PostPosted: Fri Nov 10, 2006 2:09 pm    Post subject: Problem z socketem Reply with quote

Ponizszy kod:
Code:
// includy...

int main()
{
   int i;
   struct sockaddr_in addr;

   addr.sin_family = AF_INET;
   addr.sin_port = 3000;
   addr.sin_addr.s_addr = inet_addr( "127.0.0.1" );

   int fd = ::socket( AF_INET, SOCK_STREAM, 0 );

   if ( fd < 0 )
   {
      cout << " 0 error" << endl
      << "errno: " << errno << " (" << strerror( errno ) << ')' << endl;
      exit( 1 );
   }

   i = ::bind( fd, ( struct sockaddr* ) &addr, sizeof( addr ) );

   if ( i < 0 )
   {
      cout << " 1 error" << endl
      << "errno: " << errno << " (" << strerror( errno ) << ')' << endl;
      exit( 1 );
   }

   ::sleep( 30 );

   return 0;
}


nie daje bledow jednak nie otwiera mi portu (netstat nie pokazuje ze ten port jest otwarty).

Moze mi ktos pomoc bo juz nie wiem gdzie jest blad :(
Back to top
View user's profile Send private message
kfiaciarka
Veteran
Veteran


Joined: 20 May 2005
Posts: 1498
Location: Dobre Miasto, Poland

PostPosted: Fri Nov 10, 2006 3:09 pm    Post subject: Reply with quote

ja nie wiem niestety, ale dodaj nagłówek [Programowanie] dla lepszej czytelnosci
Back to top
View user's profile Send private message
elTimo
n00b
n00b


Joined: 21 Aug 2006
Posts: 21
Location: b-stok

PostPosted: Fri Nov 10, 2006 3:40 pm    Post subject: Re: Problem z socketem Reply with quote

MarcinS21 wrote:
Ponizszy kod:
[...]
nie daje bledow jednak nie otwiera mi portu (netstat nie pokazuje ze ten port jest otwarty).

Moze mi ktos pomoc bo juz nie wiem gdzie jest blad :(


eee.. chyba brakuje funkcji listen()

tu np. prosty przyklad: http://cc-team.org/index.php?name=artykuly&show=133
_________________
elTimo
Wirtualny doradca - Rekomendacje filmów
Back to top
View user's profile Send private message
MarcinS21
n00b
n00b


Joined: 12 Feb 2006
Posts: 26
Location: Kraków

PostPosted: Fri Nov 10, 2006 4:33 pm    Post subject: Reply with quote

listen sluzy tylko do kolejkowania nadchodzacych polaczen, nie ma to wplywu na gniazdo, mam wrazenie ze chodzi tu raczej o jakis myk przy adresie, moze on zle tlumaczy ten adres i przez to sa jaja :(
Back to top
View user's profile Send private message
Raku
Bodhisattva
Bodhisattva


Joined: 28 Feb 2004
Posts: 2375
Location: Poland

PostPosted: Fri Nov 10, 2006 4:44 pm    Post subject: Reply with quote

Troszkę to niezwiązane z tematyką forum, dlatego zamknąłem. Polecam szukać pomocy w miejscu bardziej związanym z programowaniem.
_________________
raku

Powered by Archlinux ;-)
Back to top
View user's profile Send private message
argasek
Bodhisattva
Bodhisattva


Joined: 06 May 2004
Posts: 1120
Location: Sol [0,0], Poland, Kraków

PostPosted: Mon Nov 13, 2006 10:50 pm    Post subject: Reply with quote

Moved from Polish to Polish OTW.
Odmykam.
_________________
RLU #137109 | BYKOM STOP! | Chcesz do mnie napisać? | jog
"Mam plany gotowe i wszystko, no i wiesz, idę do tego, no, mebloroba..." (Raaf) :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum