Changeset 3907 in Sophya for trunk/AddOn/TAcq/swrapsock.cc


Ignore:
Timestamp:
Nov 5, 2010, 7:58:07 PM (15 years ago)
Author:
ansari
Message:

Ajout script verification donnees firmware FFT-shrink, Reza 05/11/2010

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/swrapsock.cc

    r3897 r3907  
    166166  : Socket()
    167167{
     168  Initialize(NULL, port, nconmax);
     169}
     170
     171/* --Methode-- */
     172ServerSocket::ServerSocket(const char* inadr, int port, int nconmax)
     173  : Socket()
     174{
     175  Initialize(inadr, port, nconmax);
     176}
     177
     178/* --Methode-- */
     179ServerSocket::ServerSocket(string const& inadr, int port, int nconmax)
     180  : Socket()
     181{
     182  Initialize(inadr.c_str(), port, nconmax);
     183}
     184
     185
     186/* --Methode-- */
     187void ServerSocket::Initialize(const char* str_inadr, int port, int nconmax)
     188{
    168189  int s,rc;
    169190  s = socket(AF_INET, SOCK_STREAM, 0);
    170191  if (s < 0) {
    171     cout << "ServerSocket() Pb socket() ErrNo=" <<  errno << endl; 
    172     throw SocketException("ServerSocket() Pb socket()");
     192    cout << "ServerSocket::Initialize()  Pb socketErrNo=" <<  errno << endl; 
     193    throw SocketException("ServerSocket::Initialize() Pb socket()");
    173194    }
    174195  skt = s;
     
    180201  ipskt.sin_family = AF_INET;
    181202  ipskt.sin_port = htons(port);
    182   ipskt.sin_addr.s_addr = INADDR_ANY;
     203  if (str_inadr==NULL) {   // pas d'adresse IP specifie
     204    ipskt.sin_addr.s_addr = INADDR_ANY;
     205  }
     206  else {  // adresse IP specifie sous la forme uuu.xxx.yyy.zzz.
     207    ipskt.sin_addr.s_addr = inet_addr(str_inadr);
     208  }
    183209  /* Je fais un cast explicit de sockaddr_in * (Internet) en sockaddr *   */
    184210  rc = bind(skt, (struct sockaddr *)(&ipskt), sizeof(ipskt));
    185211  if (rc < 0) {
    186212    Close();
    187     cout << "ServerSocket() Pb bind() ErrNo=" <<  errno << endl; 
    188     throw SocketException("ServerSocket() Pb bind()");
     213    cout << "ServerSocket::Initialize() Pb bind() ErrNo=" <<  errno << endl; 
     214    throw SocketException("ServerSocket::Initialize() Pb bind()");
    189215  }
    190216}
Note: See TracChangeset for help on using the changeset viewer.