💾 Archived View for rawtext.club › ~sloum › geminilist › 002445.gmi captured on 2020-11-07 at 02:54:53. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
- anridellal at yandex.ru
Wed Aug 19 14:57:54 BST 2020
- - - - - - - - - - - - - - - - - - -
Hello,
I've started writing a client for Gemini protocol, but since I've never been writing networking programs, I find myself at the dead end at the moment. Please could someone help me? When I send a request and get a response, the only thing I have in response is "gemini://" and nothing else. The code is given below:
int main() { char *locale; locale = setlocale(LC_ALL, ""); int sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { perror("socket"); exit(1); } char *url = malloc(sizeof(char)*1024); strcpy(url, "gemini://gemini.circumlunar.space/\r\n"); char rec_buf[1029] = {0}; struct hostent *host_entry; host_entry = gethostbyname(url); struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(GEMINI_PORT); addr.sin_addr.s_addr = htonl(INADDR_ANY); int opt = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { perror("setsockopt"); exit(1); } if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("bind"); exit(2); } if (connect(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("connect"); exit(3); } send(sockfd, url, sizeof(url), 0); recv(sockfd, rec_buf, sizeof(rec_buf), 0); printf("%s\n", rec_buf); close(sockfd); shutdown(sockfd, SHUT_RDWR); free(url); return 0;}
-- - <anridellal at yandex.ru>