× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: local socket object?
  • From: Dave McKenzie <davemck@xxxxxxxxxx>
  • Date: Mon, 26 Jun 2000 13:19:43 -0700

The local socket is created by the bind() call.  The 2nd parm to bind() is a
structure defined in QSYSINC/SYS(SOCKET) as:

struct sockaddr {
  u_short  sa_family;
  char     sa_data[14];
}

In other words, a 2-byte binary address-family code and 14 bytes of address
data.

When sa_family is AF_INET (=2), sa_data contains a port number and IP
address.   But for local sockets, sa_family must be AF_UNIX (=1), for which the
above structure is re-defined in QSYSINC/SYS(UN) as:

struct sockaddr_un {
  short    sun_family;
  char     sun_path[126];
}

that is, allowing a 126-byte path name for the address data.

Here's a skeleton C pgm that creates a local socket named 'asock' in IFS
directory '/home/DMTEST'.  After it runs, the socket can be seen with WRKLNK.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>

void  main(void)
{
  int                       sd;
  int                       rc;
  int                       addrLen;
  char                      IFSname[126] = "/home/DMTEST/asock";
  struct sockaddr_un        IFSaddr;

  memset(&IFSaddr, 0, sizeof(IFSaddr));
  IFSaddr.sun_family = AF_UNIX;
  strcpy(IFSaddr.sun_path, IFSname);
  sd = socket(AF_UNIX, SOCK_STREAM, 0);
  addrLen = sizeof(IFSaddr);
  rc = bind(sd, (struct sockaddr *)&IFSaddr, addrLen);
}

--Dave

Gene_Gaunt/ReviewWorks@reviewworks.com wrote:

> IBM's IFS Introduction manual says,
>
> "If your application is using the "root" (/) file system, you can take
> advantage of the IFS local socket support.  A local socket object (object
> type *SOCKET) allows two jobs running on the same system to establish a
> communications connection with each other.  One of the jobs establishes a
> connection point by using the bind() C language function to create a local
> socket object.  The other job specifies the name of the local socket object
> on the connect(), sendto(), or sendmsg() function.  The local socket object
> remains in the system until it is removed using the unlink() function or
> the Remove Link command."
>
> I don't see where bind(), connect() etc. receive object names instead of
> port numbers.  When I execute a bind(), there are no journal entry type
> 'CO' (create object) that go into QAUDJRN.   Where and when are the sockets
> created I wonder?  Using the MATAUOBJ instruction, I found some *SOCKET
> objects owned by QSYS profile but with creation time of our last IPL.  Can
> someone explain the IFS Introduction quote?

+---
| This is the MI Programmers Mailing List!
| To submit a new message, send your mail to MI400@midrange.com.
| To subscribe to this list send email to MI400-SUB@midrange.com.
| To unsubscribe from this list send email to MI400-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: dr2@cssas400.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.