summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/common.c b/common.c
index 42220cd..3779b13 100644
--- a/common.c
+++ b/common.c
@@ -200,9 +200,15 @@ SetUpConnectionSocket(
struct linger linger;
#endif /* SO_DONTLINGER */
#endif
+ char MyHostName[256];
enterprocedure("SetUpConnectionSocket");
+ (void) gethostname(MyHostName, sizeof(MyHostName));
+ ScopeHost = strdup(MyHostName);
+ if (ScopeHost == NULL)
+ panic("Can't allocate memory for hostname");
+
#ifdef USE_XTRANS
ScopePort = iport - ServerBasePort;
sprintf (port, "%d", ScopePort);
@@ -258,14 +264,7 @@ SetUpConnectionSocket(
*/
{
/* define the host part of the address */
- char MyHostName[256];
- struct hostent *hp;
-
- (void) gethostname(MyHostName, sizeof(MyHostName));
- ScopeHost = strdup(MyHostName);
- if (ScopeHost == NULL)
- panic("Can't allocate memory for hostname");
- hp = gethostbyname(MyHostName);
+ struct hostent *hp = gethostbyname(MyHostName);
if (hp == NULL)
panic("No address for our host");
bcopy((char *)hp->h_addr, (char*)&sin.sin_addr, hp->h_length);