Esempio n. 1
0
SockMsgInitResult duet_sv_init(gchar *mascotname) {
  gchar *sockname;
  SockMsgInitResult result;
  
  sockname = get_duet_name(mascotname);
  
  duet_sv = fd_connect_unix(sockname);
  if (duet_sv < 0) {
    unlink(sockname);
    duet_sv = fd_open_unix(sockname);
    if (duet_sv < 0){
      //fd_close(duet_sv);
      result = SOCKMSG_ERROR;
    }
    else
      result = SOCKMSG_CREATED;
  } else {
    // Already Opened / Closeして再オープンする。
    fd_close(duet_sv);
    unlink(sockname);
    duet_sv = fd_open_unix(sockname);
    result = SOCKMSG_OPENED;
  }
  
  return result;
}
Esempio n. 2
0
static gint create_unix_socket(void)
{
	gint uxsock;
	gchar *path;

	path = opensync_get_socket_name();
	uxsock = fd_connect_unix(path);

	if (uxsock < 0) {
		gint retVal;
		g_unlink(path);
		retVal = fd_open_unix(path);
		g_free(path);
		return retVal;
	}

	/* File already exists */
	g_unlink(path);
	g_free(path);
	return -1;
}
Esempio n. 3
0
SockMsgInitResult sockmsg_init() {
	gchar *sockname;
	SockMsgInitResult result;

	sockname = get_socket_name();


	sock = fd_connect_unix(sockname);
	if (sock < 0) {
		unlink(sockname);
		sock = fd_open_unix(sockname);
		if (sock < 0)
			result = SOCKMSG_ERROR;
		else
			result = SOCKMSG_CREATED;
	} else {
		result = SOCKMSG_OPENED;
	}

   return result;
}