send

Sending picture in Android (Socket Programming)

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:55:00
问题 I'm trying to Receive Picture on my Android phone From Server using socket programming. I use this code but in.read() in fourth line always return -1 how can i fix this problem? Client Code: try { x = new byte[picLength2]; int current = 0; int byteRead = in.read(x, 0, x.length); current = byteRead; do { byteRead = in.read(x, current, (x.length - current)); if (byteRead >0) { current += byteRead; } } while (byteRead > -1); }catch (IOException e){ e.printStackTrace(); } Server Code: try { File

Send binary file in HTTP response using C sockets

半世苍凉 提交于 2019-11-27 03:30:33
问题 I`m trying to send a binary file (png image) in http response. FILE *file; char *buffer; int fileLen; //Open file file = fopen("1.png", "rb"); if (!file) { return; } //Get file length fseek(file, 0, SEEK_END); fileLen=ftell(file); fseek(file, 0, SEEK_SET); //Allocate memory buffer=(char *)malloc(fileLen+1); if (!buffer) { fprintf(stderr, "Memory error!"); fclose(file); return; } //Read file contents into buffer fread(buffer, fileLen, 1, file); fclose(file); //free(buffer); char header[102400]

【11.5】生成器进阶--send、close和throw方法

大憨熊 提交于 2019-11-27 03:14:30
1.send方法 1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # 启动生成器有两种方法,next()和send() 4 5 6 def gen_func(): 7 # 1.可以产出值 2.可以接收值(调用方传递的值) 8 html = yield 'http://projectsedu.com' 9 print(html) 10 yield 2 11 yield 3 12 return 'zy' 13 14 15 if __name__ == '__main__': 16 # 生成生成器对象 17 gen = gen_func() 18 # 在调用send发送非None值之前,我们必须启动一次生成器,方式有两种1.gen.send(None),2.next(gen) 19 url = gen.send(None) 20 # download html 21 html = 'zy' 22 # send()可以传递值进入生成器内部,同时重启生成器执行到下一个yield位置 23 print(gen.send(html)) 24 25 # print(next(gen)) 26 # print(next(gen)) 27 # print(next(gen)) zy 2 2.close方法 1 #!/usr/bin/env

Send redirect to relative path in JSP?

 ̄綄美尐妖づ 提交于 2019-11-26 18:24:51
问题 response.sendRedirect("../seja/izpisknjig.jsp"); the file in which I execute this line is index.jsp. the directory structure looks like this. project --index.jsp seja --izpisknjig.jsp How do I form the relative path to redirect to izpisknjig.jsp. 回答1: Most reliable would be to create a domain-relative URL with the context path included. response.sendRedirect(request.getContextPath() + "/seja/izpisknjig.jsp"); 回答2: You can use JSP taglib to do redirection. Content of index.jsp file : <jsp

Sending message through WhatsApp By intent

这一生的挚爱 提交于 2019-11-26 18:16:39
问题 How I can send massage from my app to Special number in whatsapp , I know this code to share massage to group or contact on whatsapp Intent waIntent = new Intent(Intent.ACTION_SEND); waIntent.setType("text/plain"); String text = "Sorry For Interruption,I'm Just Trying Something"; waIntent.setPackage("com.whatsapp"); if (waIntent != null) { waIntent.putExtra(Intent.EXTRA_TEXT, text);// startActivity(Intent.createChooser(waIntent,"Share with")); but I want send massage to Special number like

python——生成器函数

爱⌒轻易说出口 提交于 2019-11-26 16:55:56
1.生成器 生成器的本质就是迭代器 生成器的特点和迭代器一样,取值方式和迭代器一样(__next__(),)。 send():的作用是给上一个yield传值 生成器一般由生成器函数或者生成器表达式来创建 其实就是手写的迭代器 生成器函数 和普通函数写法没有区别,里面有yield的函数就是生成器函数。 生成器函数在执行的时候,默认不会执行函数体,而是返回生成器, 通过生成器的__next__()分段执行这个函数 send():的作用是给上一个yield传值,不能在开头使用,因为没有上一个yield,最后一个yield也不可以用send,因为会报错停止生成器。 yield   yield:相当于return,可以返回数据。但是yield不会彻底中断函数。分段执行 函数中如果有yield,这个函数就是生成器函数。 生成器函数名() 获取的是生成器。这个时候不执行函数。 def func():   print('执行到第一yield,下面是返回值')   yield 1   # return和yield都可以返回数据   print('执行第一个yield不会打印这个条,再次使用gen.__next__()调用才会打印,下面是返回值')   yield 2 gen = func() # 拿到生成器,不会执行函数 gen.__next__() # 执行函数,执行到下一个yield gen._

Python Socket Send Buffer Vs. Str

梦想的初衷 提交于 2019-11-26 16:45:11
问题 I am trying to get a basic server (copied from Beginning Python) to send a str. The error: c.send( "XXX" ) TypeError: must be bytes or buffer, not str It seems to work when pickling an object. All of the examples I found, seem to be able to send a string no problem. Any help would be appreciated, Stephen import socket import pickle s = socket.socket() host = socket.gethostname() port = 80 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print( "Got Connection From ", addr )

temp

若如初见. 提交于 2019-11-26 16:42:52
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <signal.h> #include <ctype.h> #include <time.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> #include <unistd.h> #include <fcntl.h> #include <sys/time.h> #define BACKLOG 5 #define LENGTH 512 void error(const char *msg) { perror(msg); exit(1); } int tcp_send(char *ip, int PORT, char *filename) { /* Variable Definition */ int sockfd; int nsockfd; char revbuf[LENGTH]; struct sockaddr_in remote_addr; /* Get the Socket file

How send data to website by using android app

非 Y 不嫁゛ 提交于 2019-11-26 16:29:39
问题 I'm trying to send some data to my website. When the button is clicked, data need to be sent to the web site but I got some errors when I am running the program when I clicked the button this message appears "unfortunately app has stopped" then it exit my application. public class testInput extends Activity { Button Setbutton; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.test_input

Is there a limit when using php mail function?

混江龙づ霸主 提交于 2019-11-26 14:46:58
问题 I am using php and mysql. I am going to send 10k++ (ten thousands plus) emails to update my subscribers, and this is the first time I am going to send them. I will use php mail function, basically here is what I will do: First get the data from database: Select name, email FROM data After that, using while loop to send the data: while($r = mysql_fetch_assoc($exe)){ ... if($mail){ echo "success<br>"; } else { echo "failed<br>"; } } echo "Sent all"; I include the if.. else statement, to ensure