int main() { OSStatus err; void *tempmem; DNSServiceRef sdRef; DNSServiceErrorType dse; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.userwindowtitle = "\pMulticast DNS Searcher"; SIOUXSettings.rows = 40; SIOUXSettings.columns = 160; printf("DNS-SD Search Client\n\n"); printf("This software reports errors using MacsBug breaks,\n"); printf("so if you don't have MacsBug installed your Mac may crash.\n\n"); printf("******************************************************************************\n\n"); if (DNSServiceBrowse == (void*)kUnresolvedCFragSymbolAddress) { printf("Before you can use mDNS/DNS-SD clients, you need to place the \n"); printf("\"Multicast DNS & DNS-SD\" Extension in the Extensions Folder and restart\n"); return(-1); } err = InitOpenTransport(); if (err) { printf("InitOpenTransport failed %d", err); return(err); } // Make sure OT has a large enough memory pool for us to draw from at OTNotifier (interrupt) time tempmem = OTAllocMem(0x10000); if (tempmem) OTFreeMem(tempmem); else printf("**** Warning: OTAllocMem couldn't pre-allocate 64K for us.\n"); services.serviceinfolist.fHead = NULL; services.headerPrinted = false; services.lostRecords = false; printf("Sending mDNS service lookup queries and waiting for responses...\n\n"); dse = DNSServiceBrowse(&sdRef, 0, 0, "_http._tcp", "", FoundInstance, &services); if (dse == kDNSServiceErr_NoError) { while (!YieldSomeTime(35)) { if (services.serviceinfolist.fHead) PrintServiceInfo(&services); if (services.lostRecords) { services.lostRecords = false; printf("**** Warning: Out of memory: Records have been missed.\n"); } } } DNSServiceRefDeallocate(sdRef); CloseOpenTransport(); return(0); }
void SDLNet_Quit(void) { if ( SDLNet_started == 0 ) { return; } if ( --SDLNet_started == 0 ) { CloseDNS(); CloseOpenTransport(); } }
void ot_cleanup(void) { Actual_Socket s; for (s = ot.socklist; s !=NULL; s = s->next) { OTUnbind(s->ep); OTCloseProvider(s->ep); } CloseOpenTransport(); }
/*---------------------------------------------------------------------------*/ ExportFunc sword AGNetClose(AGNetCtx *ctx) { OSStatus rc = 0; if (NULL == ctx) return AG_NET_ERROR; if (AGNetIsInited) { OTCloseProvider(ctx->inet_services); CloseOpenTransport(); } return rc; }
NMErr NetworkShutdown( void ) { NMErr err = kNMNoError; /*if we have a client connection to someone, close it*/ if (_ourClientEndpoint) { if (!_clientClosing) /*so we don't somehow close twice*/ ProtocolCloseEndpoint(_ourClientEndpoint,true); /*specify an orderly disconnect*/ _clientClosing = true; } /*if we're the server, close all our endpoints and then ourself we could probably get away with just closing ourself, but just to be safe...*/ if (_ourHostEndpoint) { clientPlayer *thePlayer = _clientList; while (thePlayer) { ProtocolCloseEndpoint(thePlayer->endpoint,true);/*specifies an "orderly" disconnect*/ thePlayer = thePlayer->next; } if (!_hostClosing) /*so we don't somehow close twice*/ ProtocolCloseEndpoint(_ourHostEndpoint,true); /*specifies an "orderly" disconnect*/ _hostClosing = true; } /* Here we wait for all of our endpoints to finish closing. Otherwise our callback might be called while our app is shutting down*/ printf("\n-closing all endpoints-\n"); fflush(stdout); { while ((_clientList) || _ourHostEndpoint || _ourClientEndpoint) { NetworkHandleMessage(); } } printf("-done-\n"); fflush(stdout); #if (OP_PLATFORM_MAC_CFM) #if TARGET_API_MAC_CARBON CloseOpenTransportInContext(theOTContext); #else CloseOpenTransport(); #endif #endif return err; }
int main() { OSStatus err; RegisteredService *s; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.userwindowtitle = "\pMulticast DNS Responder"; printf("Multicast DNS Responder\n\n"); printf("This software reports errors using MacsBug breaks,\n"); printf("so if you don't have MacsBug installed your Mac may crash.\n\n"); printf("******************************************************************************\n\n"); err = InitOpenTransport(); if (err) { printf("InitOpenTransport failed %d", err); return(err); } printf("Advertising Services...\n"); #define SRSET 0 #if SRSET==0 RegisterFakeServiceForTesting(&p1, "Web Server One", "_http._tcp.", "local.", "path=/index.html"); RegisterFakeServiceForTesting(&p2, "Web Server Two", "_http._tcp.", "local.", "path=/path.html"); #elif SRSET==1 RegisterFakeServiceForTesting(&p1, "Epson Stylus 900N", "_printer._tcp.", "local.", "rn=lpq1"); RegisterFakeServiceForTesting(&p2, "HP LaserJet", "_printer._tcp.", "local.", "rn=lpq2"); #else RegisterFakeServiceForTesting(&p1, "My Printer", "_printer._tcp.", "local.", "rn=lpq3"); RegisterFakeServiceForTesting(&p2, "My Other Printer", "_printer._tcp.", "local.", "lrn=pq4"); #endif // If AFP Server is running, register a record for it CreateProxyRegistrationForRealService(&afp, "_afpovertcp._tcp.", 548, ""); // If Web Server is running, register a record for it CreateProxyRegistrationForRealService(&http, "_http._tcp.", 80, "path=/index.html"); while (!YieldSomeTime(35)) for (s = services; s; s = s->next) if (s->gotresult) { printf("%s %s %s registered\n", s->namestr, s->typestr, s->domstr); s->gotresult = false; } for (s = services; s; s = s->next) if (s->sdRef) DNSServiceRefDeallocate(s->sdRef); CloseOpenTransport(); return(0); }
void GSocket_Cleanup() { if ( gOTInited != 0 ) { if ( gInetSvcRef != NULL ) OTCloseProvider( gInetSvcRef ); #if TARGET_CARBON CloseOpenTransportInContext( NULL ) ; #else CloseOpenTransport() ; #endif if ( gOTNotifierUPP ) DisposeOTNotifyUPP( gOTNotifierUPP ) ; } }
errr report_score(void) { #ifdef MACINTOSH OSStatus err; #else errr err = 0; #endif #ifdef WINDOWS WSADATA wsaData; WORD wVersionRequested =(WORD) (( 1) | ( 1 << 8)); #endif BUF *score; int sd; char seikakutmp[128]; score = buf_new(); sprintf(seikakutmp, "%s ", ap_ptr->title); buf_sprintf(score, "name: %s\n", player_name); buf_sprintf(score, "version: Hengband %d.%d.%d\n", FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH); buf_sprintf(score, "score: %d\n", total_points()); buf_sprintf(score, "level: %d\n", p_ptr->lev); buf_sprintf(score, "depth: %d\n", dun_level); buf_sprintf(score, "maxlv: %d\n", p_ptr->max_plv); buf_sprintf(score, "maxdp: %d\n", max_dlv[DUNGEON_ANGBAND]); buf_sprintf(score, "au: %d\n", p_ptr->au); buf_sprintf(score, "turns: %d\n", turn_real(turn)); buf_sprintf(score, "sex: %d\n", p_ptr->psex); buf_sprintf(score, "race: %s\n", rp_ptr->title); buf_sprintf(score, "class: %s\n", cp_ptr->title); buf_sprintf(score, "seikaku: %s\n", seikakutmp); buf_sprintf(score, "realm1: %s\n", realm_names[p_ptr->realm1]); buf_sprintf(score, "realm2: %s\n", realm_names[p_ptr->realm2]); buf_sprintf(score, "killer: %s\n", p_ptr->died_from); buf_sprintf(score, "-----charcter dump-----\n"); make_dump(score); if (screen_dump) { buf_sprintf(score, "-----screen shot-----\n"); buf_append(score, screen_dump, strlen(screen_dump)); } #ifdef WINDOWS if (WSAStartup(wVersionRequested, &wsaData)) { msg_print("Report: WSAStartup failed."); goto report_end; } #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON err = InitOpenTransportInContext(kInitOTForApplicationMask, NULL); #else err = InitOpenTransport(); #endif if (err != noErr) { msg_print("Report: OpenTransport failed."); return 1; } #endif Term_clear(); while (1) { char buff[160]; prt("connecting...", 0, 0); Term_fresh(); /* プロキシを設定する */ set_proxy(HTTP_PROXY, HTTP_PROXY_PORT); /* Connect to the score server */ sd = connect_server(HTTP_TIMEOUT, SCORE_SERVER, SCORE_PORT); if (!(sd < 0)) break; sprintf(buff, "Failed to connect to the score server.(%s)", soc_err()); prt(buff, 0, 0); (void)inkey(); if (!get_check_strict("Try again? ", CHECK_NO_HISTORY)) { err = 1; goto report_end; } } prt("Sending the score...", 0, 0); Term_fresh(); http_post(sd, SCORE_PATH, score); disconnect_server(sd); report_end: #ifdef WINDOWS WSACleanup(); #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON CloseOpenTransportInContext(NULL); #else CloseOpenTransport(); #endif #endif return err; }